python install_error ai_generated true

RuntimeError: 表单数据需要安装"python-multipart"。

RuntimeError: Form data requires "python-multipart" to be installed.

ID: python/fastapi-form-data-requires-python-multipart

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

版本兼容性

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

根因分析

使用Form(...)或File(...)但未安装python-multipart包。

English

Using Form(...) or File(...) without the python-multipart package installed.

generic

解决方案

  1. 99% 成功率
    pip install python-multipart
  2. 97% 成功率
    echo 'python-multipart>=0.0.9' >> requirements.txt

无效尝试

常见但无效的做法:

  1. 70% 失败

    If the client sends form-encoded data, FastAPI still needs multipart to parse it.

  2. 90% 失败

    Wrong package name; FastAPI imports python_multipart.