I have the following structure:
root/
folder1/
main.py
secondary.py
folder2/
test.py
the main.py code always runs from the root folder, so on the main.py I have an
from folder1.secondary import *
so I can use its functions on main.py - that works fine
on tests.py, I do:
from root.folder1.main import myfunction
(that is the only function I need to test) but it fails saying "ModuleNotFoundError: No module named 'folder1.secondary'
root is on sys.path
I dont understand why importing main.py directly works but importing from another folder doesn't. How can I solve this problem?
Thanks
main.pydirectly) but not from a module. You need to changemain.pyto an absolute import as well:from root.folder1 import *from root.folder1.main import ...thenmainis treated as a module)