1

I have write down a code requires one module name "fragbuilder". Every thing was working fine until i have write down this code.

when I import module from command line its imported successfully but when I import same module from a script or from a IDE its showing error module not found :

and some of my previous scripts which were working fine before writing the new code but has stopped working now. :

example script given bellow:

$ python test.py 

import fragbuilder 
from fragbuilder  import peptide 
print "imported successfully"



Error: 

Traceback (most recent call last):
  File "new.py", line 3, in <module>
    import fragbuilder
  File "/usr/lib/python2.7/dist-packages/fragbuilder/__init__.py", line 1, in <module>
    from peptide import Peptide
  File "/usr/lib/python2.7/dist-packages/fragbuilder/peptide.py", line 3, in <module>
    import openbabel
  File "/usr/lib/python2.7/dist-packages/openbabel.py", line 46, in <module>
    from new import instancemethod as new_instancemethod
  File "/home/zebrafish/Desktop/edited_ds/new/new.py", line 4, in <module>
    from fragbuilder import peptide
ImportError: cannot import name peptide

what should be the probable cause of this error: please suggest thanks

1
  • It looks like your file is called new.py instead of test.py (see second line of backtrace) and that somewhere in the openbabel module imported in the fragbuilder package, something expects a module called new. So your local new.py is shadowing the expected new module and the import fails. Commented Apr 15, 2015 at 7:43

1 Answer 1

1

Likely you have added new.py to /home/zebrafish/Desktop/edited_ds/new/ which interfers with python builtin new module (should be located at /usr/lib/python2.7/new.py)

Recipe: rename new.py in your project to something else.

Sign up to request clarification or add additional context in comments.

1 Comment

yes its true, after renaming the "new.py" everything is working smoothly thanks a lot.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.