I generated a FastAPI project and all imports are relative to the src
folder:
├── src
│ └── openapi_server
│ ├── apis
│ ├── main.py
│ ├── models
│ ├── __pycache__
│ └── security_api.py
So, I have basically two options:
How can I change the pythonpath on uvicorn
execution? I found https://github.com/encode/uvicorn/pull/619 which I thought was the solution, but
~/.../src$ uvicorn main:main --reload --app-dir openapi_server/
didn't do the trick.
It's done how it's regularly done in python. Therefore, you can simply use:
~/.../src$ uvicorn openapi_server.main:main --reload