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
new.pyinstead oftest.py(see second line of backtrace) and that somewhere in theopenbabelmodule imported in thefragbuilderpackage, something expects a module callednew. So your localnew.pyis shadowing the expectednewmodule and the import fails.