python
runtime_error
ai_generated
true
RuntimeError: No application found. Either you forgot to pass an app, or you tried to access the app before it was created.
ID: python/starlette-runtime-error
80%Fix Rate
85%Confidence
0Evidence
2024-03-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Starlette 应用实例未正确初始化或未传递给服务器。
generic中文
Starlette 应用实例未正确初始化或未传递给服务器。
Workarounds
-
95% success
确保应用实例在模块级别定义,并正确传递给 uvicorn。
-
90% success
使用 uvicorn.run(app, host='0.0.0.0', port=8000)。
-
85% success
检查导入语句,确保路径正确。
Dead Ends
Common approaches that don't work:
-
80% fail
在模块级别访问 app,但应用在函数内创建。
-
70% fail
忘记在 uvicorn 中传递 app 对象。
-
60% fail
使用错误的导入路径。