albertyw / itolapi

Python API for the Interactive Tree of Life (iTOL)
MIT License
33 stars 11 forks source link

Itolapi.comm error #25

Closed brettChapman closed 6 years ago

brettChapman commented 6 years ago

Hi

Thanks for updating itolapi. I've found an error when running the tree of life example you provided.

ModuleNotFoundError Traceback (most recent call last)

in () 2 import sys 3 ----> 4 from itolapi import Itol, ItolExport # NOQA 5 6 test = Itol() ~/anaconda3/lib/python3.6/site-packages/itolapi/__init__.py in () ----> 1 from itolapi.comm import Comm # NOQA 2 from itolapi.itolexport import ItolExport # NOQA 3 from itolapi.itol import Itol # NOQA ModuleNotFoundError: No module named 'itolapi.comm'
albertyw commented 6 years ago

Are you using the current version of itolapi? What do you get with pip freeze | grep itolapi?

brettChapman commented 6 years ago

I get itolapi==3.0.0 which is your current version.

I've been running the python scripts through Jupyter as we'd like to provide a workflow environment and embed the images.

brettChapman commented 6 years ago

I just tried outside of Jupyter and I get the same error:

MHD81750118:examples bschapma$ python ./example.py Traceback (most recent call last): File "./example.py", line 14, in from itolapi import Itol, ItolExport # NOQA File "/Users/bschapma/anaconda3/lib/python3.6/site-packages/itolapi/init.py", line 1, in from itolapi.comm import Comm # NOQA ModuleNotFoundError: No module named 'itolapi.comm'

albertyw commented 6 years ago

I haven't been able to reproduce this issue myself even on a fresh virtualenv so I still suspect that the issue is from your setup, probably that the pip version is different from your imported version. What's the version under /home/albertyw/.virtualenvs/test/lib/python3.6/site-packages/itolapi/__version__.py?

brettChapman commented 6 years ago

In version.py is VERSION = (3, 0, 0).

I've also tried uninstalling itolapi and reinstalling from pip. I've also updated pip. I still get the same error.

This is my version of pip: pip 18.0 from /Users/bschapma/anaconda3/lib/python3.6/site-packages/pip (python 3.6)

brettChapman commented 6 years ago

I've now tested it in a new python 3.6 virtual environment I set up in Anaconda. I then upgraded pip and I still get the same error.

albertyw commented 6 years ago

Try this:

pip install -e git://github.com/albertyw/itolapi.git@06d34b1c3883dcf2669bd1cae0add6ecfc29ff96#egg=itolapi
brettChapman commented 6 years ago

I tried that and I got this error: (base) MHD81750118:~ bschapma$ pip install -e git://github.com/albertyw/itolapi.git@06d34b1c3883dcf2669bd1cae0add6ecfc29ff96#egg=itolapi Obtaining itolapi from git+git://github.com/albertyw/itolapi.git@06d34b1c3883dcf2669bd1cae0add6ecfc29ff96#egg=itolapi Cloning git://github.com/albertyw/itolapi.git (to revision 06d34b1c3883dcf2669bd1cae0add6ecfc29ff96) to ./src/itolapi fatal: unable to connect to github.com: github.com[0: 192.30.255.113]: errno=Operation timed out github.com[1: 192.30.255.112]: errno=Operation timed out

I then tried: pip install git+https://github.com/albertyw/itolapi.git

and this time it installed. I then ran the example.py you provided on GIT and it now works.

That is weird that installing directly from pypi caused the itolapi.comm error.

Thanks for your help.

albertyw commented 6 years ago

I'm pretty sure that you have an itolapi file or directory/module somewhere along your sys.path that is being loaded before the proper itolapi package from pip is being found and imported. By installing itolapi directly from github, it looks like you're saving files to ./src/itolapi which is going to add another override to where pip is installing packages. Anyways, I've released https://github.com/albertyw/itolapi/commit/248bc144dd93c8b6ec87eca0f00ef0716f200cfd that uses relative imports so it should find the correct files to import in the future (though you will need to remove your other itolapi files.