moltemplate installation problem (can't open file charge_by_bond.py)

Dear LAMMPS users:

I got a problem in running moltemplate. The issue was reported in the maillist earlier, but not solved. Could anyone give me some suggestions? Thank you.

I use pip to install moltemplate on my macOS (Mojave 10.14.1) and CentOS linux

pip install moltemplate

The python distribution is

Python 3.6.4 :: Anaconda, Inc.

Then when I run the examples by

sh README_remove_irrelevant_info.sh
sh README_setup.sh

the following errors were reported

Looking up partial charge contributions from bonds
python: can’t open file ‘/Users/xuzp/anaconda3/bin/charge_by_bond.py’: [Errno 2] No such file or directory
mv: rename system.data to …/system.data: No such file or directory
mv: rename system.in* to …/system.in*: No such file or directory

If I copy the file charge_by_bond.py from the src directory to the installed directory, the following error msg will be reported

Looking up partial charge contributions from bonds
Traceback (most recent call last):
File “/Users/xuzp/anaconda3/bin/charge_by_bond.py”, line 17, in
from . import ttree_lex
ImportError: cannot import name ‘ttree_lex’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Users/xuzp/anaconda3/bin/charge_by_bond.py”, line 21, in
import ttree_lex
ModuleNotFoundError: No module named ‘ttree_lex’
mv: rename system.data to …/system.data: No such file or directory
mv: rename system.in* to …/system.in*: No such file or directory

Thank you.

Best,
Zhiping

Andrew can comment (CCd).
I don’t think you should need to manually copy files into Anaconda.

Steve

Dear Zhiping

   My apologies. I've been in China for a few weeks, and I was too
lazy to figure out how to check my gmail messages while I was there.
I just got back a couple days ago and am slowly going through old
emails.

    1) Firstly, thank you very much for reporting the bug. The issue
you reported is new (to me) and serious enough that I will fix it
soon. The problem appears to be specific to pypi, not anaconda. (I
am using python 3.6.5 with anaconda as well.)

   2) Request:
   I just uploaded a new version of moltemplate to pypi. (version
2.10.5) Can you try uninstalling moltemplate and then running "pip
install moltemplate" again? Does that solve your issue? (Please
reply only to me. No need to continue the debugging conversation on
the mailing list.)

   3) In the mean time, you should be able to get around the problem
by downloading moltemplate from git using:
git clone https://github.com/jewettaij/moltemplate moltemplate
(or just click on the "releases" link, and download a .zip or .tar.gz file)

    and installing it by going to the moltemplate directory and entering

pip install .

4) ... another pypi-specific bug:

   (missing force fields when using "pip install moltemplate")

I have occasionally run into bugs when using "pip install moltemplate"
(ie using pypi to download moltemplate instead of github). If you
installed it that way, then ".lt" files that contain force fields, and
some random stuff like popular water molecules might not get copied to
the correct place. If you use any of these force fields or water
molecules in your simulations, moltemplate will complain that it can't
find the .lt file for that force field. (eg "oplsaa.lt").

   If you run into this problem, there are 2 easy solutions:

a) Just download the file you need from:
https://github.com/jewettaij/moltemplate/tree/master/moltemplate/force_fields/
...and then move it to the directory where you are running
moltemplate, and try running moltemplate.sh again.
b) Alternatively, try downloading moltemplate from git instead
(bypassing pypi), and install it by changing to the "moltemplate"
directory and entering:
pip install .
(instead of "pip install moltemplate")
    This problem only occurred when python 3, not python 2.7, in
conjunction with pypi. And, again, this problem never occurred when
downloading moltemplate directly from git (or from the moltemplate.org
web page, regardless of whether you were using python 3 or 2.7). The
bug is probably in the "package_data" section of the "setup.py" file:

package_data={'moltemplate': ['force_fields/*.lt']}

...because the .LT files in the "force_fields" directory are not being
copied to the correct location (when using "pip install moltemplate"
in python 3). I have been too lazy to figure out why this is going
on, but I'm open to suggestions.

   Until then, I generally suggest people use git and avoid pypi. If
you think this issue is serious enough to remove moltemplate from
pypi, I will consider that.

Cheers and thanks again for reporting this bug.
Andrew

4) ... another pypi-specific bug:
   (missing force fields when using "pip install moltemplate")
I have occasionally run into bugs when using "pip install moltemplate"
(ie using pypi to download moltemplate instead of github). If you
installed it that way, then ".lt" files that contain force fields, and
some random stuff like popular water molecules might not get copied to
the correct place.

I think I solved this problem.
For the record, moltemplate should now work without issue when installed using
"pip install moltemplate", and I will try to keep it that way.
Please let me know if you're still having trouble.

Andrew