python module_error ai_generated true

ModuleNotFoundError: 没有名为 'starlette' 的模块

ModuleNotFoundError: No module named 'starlette'

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

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2024-01-20首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

当前 Python 环境中未安装 Starlette。

English

Starlette is not installed in the current Python environment.

generic

解决方案

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

无效尝试

常见但无效的做法:

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

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