I have a package with several nested modules:
somepackage/
module1/
__init__.py
module2/
__init__.py
to_be_imported.py
setup.py
I have installed this package with python setup.py develop
. The to_be_imported.py
file contains a few classes and a method (after the classes, since the method uses some classmethods of the classes). After opening an IPython console, the following import works:
from somepackage.module1.module2.to_be_imported import SomeClass
but this one fails with ImportError:
from somepackage.module1.module2.to_be_imported import my_method
Moreover, if I import the file as
from somepackage.module1.module2 import to_be_imported
and print the imported file content, it prints my_method
too!
I am confused about what causes the import error, does anybody encountered such problems?