There is such a file structure:
root |--project1 | |--__init__.py | |--subrunner.py | |--proc.py |--project2 |--projectN |--runner.py runner.py
from project1.subrunner import foo foo() subrunner.py
This version of import:
from proc import bar def foo(): bar() allows you to run a subrunner , but when you run runner we get the error: ModuleNotFoundError: No module named 'proc' .
And this version of import:
from .proc import bar relative through the dot, vice versa. Allows you to run the runner , but when you start the subrunner we get the error: ModuleNotFoundError: No module named '__main__.proc'; '__main__' is not a package ModuleNotFoundError: No module named '__main__.proc'; '__main__' is not a package
How to do the import correctly, so that it works both when the runner started and when the subrunner started?