I encountered a ModuleNotFoundError
when attempting to import my MongoDB configuration from config.py
into my routes.py
file located in the routers
folder. Here’s the import statement causing the issue:
`from app.config import db ModuleNotFoundError: No module named 'app'`
app
├── config.py
├── Dockerfile
├── __init__.py
├── main.py
├── models
│ ├── __init__.py
│ └── Models.py
├── routers
│ ├── datas.py
│ ├── __init__.py
│ └── users.py
└── schemas
├── dicto.py
├── __init__.py
└── states.py
I run the project from app dir and also tried this import method:
from ..config import db
New contributor
Reza is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.