ERROR pip build_error ai_generated true

error: command 'gcc' failed: No such file or directory. ERROR: Failed building wheel for <package>

ID: pip/src-install-failed

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
50Evidence
2022-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
24 active

Root Cause

Building a package from source failed because required compiler (gcc/g++) or development libraries are missing. Happens when no prebuilt wheel is available and pip falls back to source distribution.

generic

Workarounds

  1. 90% success Install C compiler and Python development headers
    apt-get install build-essential python3-dev && pip install <package>
  2. 85% success Install package-specific system dependencies
    Check the package docs for required system libs. Example: apt-get install libxml2-dev libxslt-dev for lxml
  3. 82% success Use a pre-compiled wheel from piwheels or conda-forge
    pip install --extra-index-url https://www.piwheels.org/simple <package>  # or: conda install <package>

Dead Ends

Common approaches that don't work:

  1. Install the package with --prefer-binary and hope for the best 65% fail

    If no binary exists, --prefer-binary still falls back to source and fails the same way

  2. Set CC=/usr/bin/gcc without actually installing gcc 99% fail

    Setting the environment variable does not install the compiler; the file must exist

Error Chain

Leads to:
Preceded by:
Frequently confused with: