python install_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-06-09First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —
3.13 active — — —

Root Cause

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

中文

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

Workarounds

  1. 80% success
    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% success
    FROM python:3.11-slim
    RUN pip install cryptography
  3. 70% success
    pip install 'cryptography<42'

Dead Ends

Common approaches that don't work:

  1. 55% fail

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

  2. 80% fail

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

  3. 85% fail

    Force reinstall re-triggers the same source build path.