My project has basically an architecture like this:
src
├── __init__.py
├── main.py
└── core
├── __init__.py
├── module1.py
└── module2.py
All __init__.py
files are empty, in main.py
I have a from src.core.module1 import stuff
and I am running main.py
from the src
folder. When I'm running it from my project virtual environment everything works fine, but outside of the virtual environment I have an ImportError: no module named src.core.module1
. I cannot understand why, because this module is in the project, not related to the Python environment packages...
(Windows / Python 2.7.14)
Try from core.module1 import stuff
. You should not import src
since you are in that location with your main.py already.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.