Similar questions have been asked many times, but I didn't find a solution yet. I have Python Project that is structured as follows (simplified version).
The problem is to import module1
in myscript.py
.
So far, I've written sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..'))
on top of myscript.py
, but this is not very elegant and I wonder what's the best structure for my project that can easily import modules from the project to scripts that are located in a separate folder.
project
--project
----module1.py
----module2.py
----__init__.py
--examples
--scripts
---myscript.py
--Readme.md