python system_error ai_generated true

error: command 'gcc' failed: No such file or directory × Building wheel for lxml (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> error: command 'gcc' failed with exit status 1

ID: python/setuptools-native-ext-build-failure

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-03-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

No C compiler (gcc/clang) is installed, so pip falls back to building a C extension from source and fails immediately.

generic

中文

未安装 C 编译器(gcc/clang),因此 pip 回退到从源码构建 C 扩展并立即失败。

Workarounds

  1. 92% success
    # Debian/Ubuntu
    sudo apt install build-essential python3-dev libxml2-dev libxslt1-dev
    # macOS
    xcode-select --install
    # then
    python -m pip install lxml
  2. 90% success
    python -m pip install --only-binary=:all: lxml
    # or pin a version that ships wheels for your platform
    python -m pip install 'lxml==5.2.2'

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Build tools are fine; the missing piece is the system C compiler.

  2. 90% fail

    Still attempts the source build and hits the same gcc error.