python module_error ai_generated true

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

ModuleNotFoundError: No module named 'uvicorn'

ID: python/starlette-no-module-named-uvicorn

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

版本兼容性

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

根因分析

FastAPI/Starlette 不内置 ASGI 服务器;当前环境中未安装 uvicorn。

English

FastAPI/Starlette does not bundle an ASGI server; uvicorn was never installed in the active environment.

generic

解决方案

  1. 95% 成功率
    Install server extra:
    pip install 'fastapi[standard]'  # or: pip install uvicorn
  2. 85% 成功率
    Verify the interpreter matches:
    which python && python -m uvicorn --version

无效尝试

常见但无效的做法:

  1. 80% 失败

    fastapi does not depend on uvicorn by default.

  2. 85% 失败

    The module import still fails before any server starts.