I have a project structure, like so:
└── auto/
│ ├──── __init__.py
│ └──── __pycache__/
│ ├──── deploy
│ ├──── destroy
│ └──── helpers/
│ │ ├──── __init__.py
│ │ ├──── cli.py
│ │ └──── zip.py
│ └──── synth
└── src/
│ ├──── __init__.py
│ ├──── main.py
│ └──── models/
│ │ ├──── __init__.py
│ │ ├──── filter.py
│ │ └──── json_extract_config.py
│ └──── utils/
│ │ ├──── __init__.py
│ │ └──── json_extractor.py
I am trying to call the script synth
in the ./auto/synth location.
The synth file is a script with a shebang at the top #!/usr/bin/env python3
It imports a function from the ./auto/helpers/zip.py file.
When I run, ./auto/synth
from the root folder it throws an error:
from auto.helpers.zip import zip_folder
ModuleNotFoundError: No module named 'auto'
Although when I run PYTHONPATH="$PWD" ./auto/synth
the script executes successfully.
Can someone help me understand this behaviour and how to avoid it so that my scripts can be run normally without having to change the PYTHONOPATH?
Thanks in advance.