Error loading ASGI app. Attribute "app" not found in module "main".
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
Description
I was trying th basic code given on fastapi to verify my FASTAPI installation. I tried to execute above code with following command ‘uvicorn main:app --reload’ but got the bellow error
INFO: Will watch for changes in these directories: [‘D:\FASTAPI’] INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [7900] using watchgod ERROR: Error loading ASGI app. Attribute “app” not found in module “main”.
Operating System
Windows
Operating System Details
windows 10
FastAPI Version
0.70.0
Python Version
3.9.6
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
FastAPI throws an error (Error loading ASGI app. Could not ...
Could not import module "main". The answer is so simple, add the folder name in front of your filename uvicorn src.main:app --reload.
Read more >FastAPI Error loading ASGI app. Could not import module 'main'
The FastAPI Error loading ASGI app. Could not import module 'main' occurs when your terminal is located in a directory that doesn't contain...
Read more >Error loading ASGI app. Could not import module "main"
Install the software on Ubuntu, accidentally upgrade PIP, resulting in the use Times as follows: Later, it was found that this problem was...
Read more >tiangolo/fastapi - Gitter
Hello there, if the main script of my app has not '.py' extension, I have the next error: ERROR: Error loading ASGI app....
Read more >Settings - Uvicorn
Also note that UVICORN_* prefixed settings cannot be used from within an ... APP - The ASGI application to run, in the format...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi @sudoalger , please use
uvicorn src.main:app
instead ofuvicorn src.main::app
That’s a good intention, but in your case (as I see it), the crucial parts people have to see in order to give useful advice how to solve your problem are missing.
Again, this looks like a problem of code organisation (how to avoid the circular import). Actually, I think you can build in the example from the fastapi-socketio docs: Just move the declaration of the socket handlers into a separate module and mount the socket manager in your app in
main.py
.So
and I’m pretty sure you will get the advice you need in no time