Reputation: 373
I know usually it is something about project structure that raises this error.
But my project structure is the simplest one:
.
├── blog.db
├── database.py
├── main.py
├── models.py
├── poetry.lock
├── __pycache__
│ ├── database.cpython-39.pyc
│ ├── main.cpython-39.pyc
│ ├── models.cpython-39.pyc
│ ├── schemas.cpython-39.pyc
│ └── services.cpython-39.pyc
├── pyproject.toml
├── requirements.txt
├── schemas.py
└── services.py
Yet every time I run
uvicorn main:app --reload
I get
ERROR: Error loading ASGI app. Could not import module "main".
So what exactly am I doing wrong if I have all my files in the same folder?
Upvotes: 0
Views: 4954
Reputation: 31
I have the same problem with running fastAPI. After checking the file path and everything, I figure the solution is very simple. You just need to save your python file (in this case "main.py") before run uvicorn command on cmd. That's it.
Upvotes: 3