I have a project structured as such:
folder1
|
folder2
|
tests
I have __init__.py in each folder. When I am in the parent directory of folder1, I run iPython and do
from folder1.folder2.tests.test1 import main
main()
everything works fine. However when I run
python folder1/folder2/tests/test1.py
I get ImportError: No module named folder1.folder2.file1, where my import statement in test1 is
from folder1.folder2.file1 import class1
Confused about this - I am guessing it is a path issue but I don't understand what is wrong with my code (many similar setups in other folders) and why it still works in iPython and not python run as a script.