python install_error ai_generated true

错误:无法为 cryptography 构建 wheel,而它是安装基于 pyproject.toml 的项目所必需的

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

ID: python/error-could-not-build-wheels-for-package

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

版本兼容性

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

根因分析

由于当前平台/Python ABI 没有匹配的 wheel,某个依赖必须从源码编译。当解释器比包的 wheel 矩阵更新,或在 musl/Alpine 上 manylinux wheel 不兼容时会发生。

English

A dependency must be compiled from source because no matching wheel exists for the current platform/Python ABI. This happens when the interpreter is newer than the package's wheel matrix, or on musl/Alpine where manylinux wheels are incompatible.

generic

解决方案

  1. 80% 成功率
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
    pip install cryptography
  2. 90% 成功率
    FROM python:3.11-slim
    RUN pip install cryptography
  3. 70% 成功率
    pip install 'cryptography<42'

无效尝试

常见但无效的做法:

  1. 55% 失败

    Upgrading tools does not produce a wheel for an unsupported ABI; build still fails.

  2. 80% 失败

    Cache is not the issue; the wheel simply does not exist for this platform.

  3. 85% 失败

    Force reinstall re-triggers the same source build path.