python scripts / main.py
in the project directory.Directory structure
project/
├ module/
│ └ module1.py
└ scripts/
└ main.py
main.py
import sys
sys.path.append('..')
from module import module1
If nothing is done, ModuleNotFoundError
will be displayed.
..
indicates the parent directory as seen from the ** working directory **. ** Not the directory containing the executable **. That is, it refers to the parent directory for the project directory.
As a solution, it can be executed as a module.
python -m scripts.main
Recommended Posts