clauswilke/PeptideBuilder

import PeptideBuilder fails with Python 3.5.2

Closed this issue · 6 comments

Importing PeptideBuilder under Python 3.5.2 gives the following error on both Mac OS and Windows:

Python 3.5.2 (default, Oct 11 2016, 04:59:56) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PeptideBuilder
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/PeptideBuilder/__init__.py", line 10, in <module>
    from .PeptideBuilder import *
  File "/usr/local/lib/python3.5/site-packages/PeptideBuilder/PeptideBuilder.py", line 25, in <module>
    from Geometry import *
ImportError: No module named 'Geometry'
>>> 

Re-installing PeptideBuilder via pip did not resolve the error.

mtien commented

You're missing the Geometry.py library. Not sure if you pip "PeptideBuilder" that the "Geometry" library will also be added. I'm not familiar with pip since I've been out of touch with this for a while. Try downloading Geometry.py and add it manually to your python path.

My apologies,
Matthew

It works fine with Python 2.7 though. Perhaps namespaces/imports are handled differently in the newest versions of Python3? I can fix these errors if I manually go in and replace all instances of import Geometry with import PeptideBuilder.Geometry.

EDIT: Seems related to this:

http://www.diveintopython3.net/porting-code-to-python-3-with-2to3.html#import

mtien commented

Ah. Good catch. Curious if this is the only thing that will need to be worked out between using Python 3 vs 2.7

Yes. Line 25 in PeptideBuilder.py is currently

from Geometry import *

and it should be

from .Geometry import *

I think everything else should be fine. We had already converted all the print functions a while back, see issue #2.

I fixed the import statements and unit tests and bumped up the version number. Could someone upload the new version to PyPI?