python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'starlette'
ID: python/starlette-import-error-no-module-named-starlette
80%Fix Rate
85%Confidence
0Evidence
2024-01-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Starlette is not installed in the current Python environment.
generic中文
当前 Python 环境中未安装 Starlette。
Workarounds
-
95% success Install Starlette using pip.
pip install starlette
-
90% success Install FastAPI which includes Starlette.
pip install fastapi
Dead Ends
Common approaches that don't work:
-
Installing starlette with pip but using a virtual environment not activated.
80% fail
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% fail
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.