I am working on a project structured in the following way:
repo-name/
.venv
src/
__init__.py
module1.py
module2.py
scratches/
script1.py
poetry.lock
pyproject.toml
In script1.py I would like to use the classes defined in module1.py and module2.py, thus the file looks like:
#repo-name/scratches/script1.py
import src.module1 as m1
I am using Pycharm as IDE and I have marked src as source directory. If I run script1.py in Pycharm I do not get any error. However if I navigate into repo-name/scratches/ and run poetry shell and then run python script1.py I get the following error:
ModuleNotFoundError: No module named 'src'
The absolute import cannot start from repo-name due to "-" in the name of the repository.
Is there any solution to run the script without changing the structure of the repository?