>>> from foo.bar import app
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named foo.bar
My directory structure:
In /foo:
__init__.py
bar.py
In /foo/tests:
__init__.py
testing.py
In /foo/tests/testing.py I need to import app from /foo/bar.py. I get the ImportError if I run the testing.py file.
I have checked sys.path and the /foo and /foo/tests folders are included.
If /foo is on
sys.path, then you can import bar usingimport bar, so try changing the import line in testing.py to the following:Alternatively, put the root folder on
sys.path, which will allow you to import the modulefooand its contents usingimport foo.XXX,from foo import XXX, orfrom foo.XXX import YYY.