python module_error ai_generated true

ModuleNotFoundError: No module named 'starlette'

ID: python/starlette-import-error-no-module-named-starlette

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Starlette is not installed in the current Python environment.

generic

中文

当前 Python 环境中未安装 Starlette。

Workarounds

  1. 95% success Install Starlette using pip.
    pip install starlette
  2. 90% success Install FastAPI which includes Starlette.
    pip install fastapi

Dead Ends

Common approaches that don't work:

  1. 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.

  2. 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.