I have the following file tree and the console gives me the following error:
Traceback (most recent call last):
File "C:\Flask\APP-POWERBY\src\app.py", line 6, in <module>
from services.embedded import all_reports, all_workshop2
ModuleNotFoundError: No module named 'services'
I am importing the two definitions (all_reports, all_workshop2) with
from services.embedded import all_reports, all_workshop2 from the app.py file
what is wrong with me?
The issue may be that you are running the script using
python src/app.py. In this case,
src will be included in the
sys.path. However, since
services.py is located in the parent directory of
src, it cannot be detected by the interpreter.
src/ # <- module search path
To fix this, run
python -m src.app from the
app-powerby project folder, and the current directory will be added to
app-powerby # <- module search path
services is under the search path and can be imported without problem.