python
module_error
ai_generated
true
ModuleNotFoundError: 没有名为 'starlette' 的模块
ModuleNotFoundError: No module named 'starlette'
ID: python/starlette-import-error-no-module-named-starlette
80%修复率
85%置信度
0证据数
2024-01-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
当前 Python 环境中未安装 Starlette。
English
Starlette is not installed in the current Python environment.
解决方案
-
95% 成功率 Install Starlette using pip.
pip install starlette
-
90% 成功率 Install FastAPI which includes Starlette.
pip install fastapi
无效尝试
常见但无效的做法:
-
Installing starlette with pip but using a virtual environment not activated.
80% 失败
If the virtual environment is not activated, the package is installed in the system Python, not the project's environment.
-
Assuming starlette is included with FastAPI.
60% 失败
FastAPI depends on Starlette, but if you install only FastAPI, Starlette is installed as a dependency. However, if you uninstall FastAPI, Starlette may also be removed.