I am trying to run a python file from terminal. It has a bunch of imports from modules I wrote, and those modules also import from other modules from throughout my project. As PyCharm was my main editor, I could mark the src directory as Sources Root, which allowed me to import other modules in two ways. Say I have a module shared, I could import from it as:
from src.shared.timer import Timer
But also as:
from shared.timer import Timer
When I run my script main.py from within pycharm everything runs perfectly The problem is that when I run main.py from command line, my imports give error "No module named shared" or "No module named src" depending on whether I call from the top-level directory or from the src directory. Either way, I can never get all imports right. Is there a way to mark my src directory as Sources Root, similar to in PyCharm? I want to avoid refactoring everything and then finding out there is some other issue.
from top level directory in repository, I tried to run
python3.8 -m src.main.py
and got
ModuleNotFoundError: No module named 'shared'