Moltemplate installation

Hello everyone.!

I am facing a trouble to install the moltemplate.

I have attached a snapshot of my problem.

Help me in this regard.

moltemplate 2017-08-19.png

Hello everyone.!

I am facing a trouble to install the moltemplate.
I have attached a snapshot of my problem.

​is there anywhere in the moltemplate documentation where it says it can be
installed via pip?


Dear Axel,

It is there in moltemplate manual if we understand it correctly and are not wrong. Can you please suggest correct way to install it?

Thank you.


Dear Varsha,
You can install it using correct command

pip install . --user

Thanks Rajesh
Sorry for the slow reply Varsha

I never bothered to registered moltemplate with PyPI. Perhaps I should. (That’s why you currently can’t install it using “pip install moltemplate”)

Instead you must manually download moltemplate at (and unpack it if you got the gzipped version), and install it by running:

pip install .

…from within the moltemplate directory that you downloaded. (The directory containing

Documentation is available here:


Dear Andrew,
Thank you for your response. Only pip install . Doesn’t work and give some error due to permission issue. I used pip install . --user command to install it.

Thank you

Thanks Andrew, and Rajesh.

Still I am not able to install moltemplate by using both the commands.

moltemp (2) 2017-08-22 09-26-02.png

moltemp (error) 2017-08-22.png

Some apologies to follow.

There is some confusion because there are 3 versions of moltemplate
being distributed, and PIP compatibility currently depends on which
version you are using. I'll fix this today.

  1) the version available from This is the version which
is most up to date. This version does not have the PIP/packaging
issue that Varsha found. You can install it using PIP using "pip
install . --user" (thanks Rajesh)

  2) the version available at (as
a .tar.gz file). Unfortunately, this version has a problem with PIP
which Varsha just discovered (in the 2017-4-17 version). This is
really embarrassing. I will fix this and post a new file on this
website today.

  3) the version of moltemplate which is distributed with LAMMPS.
This is probably the most stable version. However it does not yet
work with PIP. (Thanks Axel for pointing this out.)

All 3 versions work and can still be installed the "old fashioned"
way: by manually editing your .bashrc file to change your $PATH
environment variable. I'll make some updates today to eliminate these
discrepancies so that PIP works on all of them.

More comments to follow:

pip install . --user

Thanks Rajesh for pointing this out. The "--user" flag is necessary
in some operating systems, if you don't have admin privileges. (I was
not aware of this issue because the versions of PIP which are packaged
with ubuntu install python packages in ~/.local by default. Other
linux flavors like arch, do it differently.) I will change
installation instructions.

Another alternative is to use "virtualenv". Virtualenv creates a
temporary python package environment where you can safely experiment
with installing python packages without risk of messing up your
system, and it temporarily and reversibly updates your $PATH variable
as well.) I highly recommend installing "virtualenv" and installing
moltemplate this way:

git clone ~/moltemplate
cd ~/moltemplate
virtualenv venv
source venv/bin/activate
pip install .

The only drawback to installing moltemplate with virtualenv is that
whenever you want to run moltemplate, you will have to run the "source
~/moltemplate/venv/bin/activate" command in your shell at some point
beforehand. (In addition to this issue, python modules you use
frequently, such as numpy, will not be installed in this new
environment, and you will have to run commands like "pip install
numpy" if you need them. Moltemplate might require numpy in the

I'm grateful people are posting difficulties with moltemplate.
I'll clean this up today.


should all be working now.

("pip install moltemplate" and/or "pip install moltemplate --user"
should finally be working too.)
Thanks again for the bug reports.

Dear Andrew
Thanks for this step. Now its very easy to install moltemplate. Great effort.

Thank you

Hello Andrew,

I tried the above commands also. And it shows - Requirement already satisfied: moltemplate in /home/admin-pc/.local/lib/python2.7/site-packages

I don’t understand that moltemplate has been installed or not.

Hello Andrew,

I tried the above commands also. And it shows - Requirement already
satisfied: moltemplate in /home/admin-pc/.local/lib/python2.7/site-packages

I don't understand that moltemplate has been installed or not.

It sounds as though pip thinks it has.

However if you downloaded moltemplate in the last 48 hours, I would
reinstall it to be safe.
(Yesterday I introduced a nasty bug which I fixed about an hour ago.
I was too lazy to update the name of the file on the web page, but it's been fixed too. I
sent Axel the update so it will hopefully be included with future
versions of LAMMPS)

...I digress
Try this:

pip uninstall moltemplate
(or something like "pip uninstall moltemplate --user", if that fails)

Then try downloading moltemplate again and using "pip install . --user"

(Or try your luck with "pip install moltemplate --user")

Hopefully this works. If not let me know. (I'd feel a bit guilty if
previous broken versions of moltemplate are somehow corrupting
everyone's python __. But if I did, I'm guessing it shouldn't be too
hard to fix. But this is an argument for using the "virtualenv" trick
I mentioned in a previous post.)



Hi Andrew,

No… Now you don’t need to be feel guilty. Because now it has been installed in my system.

And Thanks a Ton Rajesh…!