jax
jax

Reputation: 4197

import error in python

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

Upvotes: 1

Views: 256

Answers (1)

user3159253
user3159253

Reputation: 17455

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.

Upvotes: 1

Related Questions