ModuleNotFoundError: No module named 'app.routes'
So I'm learning fastapi right now and I was trying to separate my project into multiple files but when I do I get this error.
ModuleNotFoundError: No module named 'app.routes'
I have read This multiple times and I'm pretty sure I did everything right can anyone tell me what I did wrong?
app
│ main.py
│ __init__.py
│
└───routes
auth.py
__init__.py
main.py
from fastapi import FastAPI
from app.routes import auth
app = FastAPI()
app.include_router(auth.router)
auth.py
from fastapi import APIRouter
router = APIRouter()
@router.get("/test")
async def test():
return {"test": "test"}
I ran uvicorn main:app --reload
Just run below command
export PYTHONPATH=$PWD
Your uvicorn command is slightly off. From whatever directory is above app
run --
uvicorn app.main:app --reload