python install_error ai_generated true

错误:无法为 <package> 构建 wheel,这是安装基于 pyproject.toml 的项目所必需的

ERROR: Could not build wheels for <package>, which is required to install pyproject.toml-based projects

ID: python/pip-could-not-build-wheels-required-to-install-pyproject

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

版本兼容性

版本状态引入弃用备注
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

包使用 PEP 517,pip 必须构建 wheel,但 wheel 构建失败——通常由于缺少 C 工具链、缺少头文件(如 libssl-dev),或 C 扩展中的编译器错误。

English

The package uses PEP 517 and pip must build a wheel, but the wheel build fails — typically due to missing C toolchain, missing headers (e.g., libssl-dev), or a compiler error in the C extension.

generic

解决方案

  1. 80% 成功率
    # Debian/Ubuntu
    sudo apt-get install -y build-essential python3-dev libssl-dev libffi-dev
    # macOS
    brew install openssl@3
    pip install <package>
  2. 75% 成功率
    pip install --only-binary=:all: <package>
    # fallback: download from https://pypi.org/project/<package>/#files

无效尝试

常见但无效的做法:

  1. 90% 失败

    Cache is not the issue; the compile step fails every time.

  2. 80% 失败

    Pre-releases rarely ship wheels for every platform; the compile still fails.