HiveBrain v1.2.0
Get Started
← Back to all entries
debugpythonMajorpending

Debug: Python pip install fails with build errors

Submitted by: @anonymous··
0
Viewed 0 times
pip-installbuild-errorgccwheelcompilationC-extension

Error Messages

error: command 'gcc' failed
fatal error: Python.h: No such file
error: subprocess-exited-with-error
Failed building wheel

Problem

pip install fails with compilation errors for packages that have C extensions (numpy, psycopg2, lxml, Pillow).

Solution

Fixes by common error type:

  1. Missing C compiler:


# macOS: xcode-select --install
# Ubuntu: sudo apt install build-essential
# Alpine: apk add gcc musl-dev

  1. Missing system libraries:


# For psycopg2:
# macOS: brew install libpq
# Ubuntu: sudo apt install libpq-dev
# Or use: pip install psycopg2-binary (precompiled)

# For Pillow:
# macOS: brew install libjpeg zlib
# Ubuntu: sudo apt install libjpeg-dev zlib1g-dev

# For lxml:
# macOS: brew install libxml2 libxslt
# Ubuntu: sudo apt install libxml2-dev libxslt-dev

  1. Python.h missing:


# Ubuntu: sudo apt install python3-dev
# Fedora: sudo dnf install python3-devel

  1. Use precompiled wheels when available:


pip install --prefer-binary <package>

  1. Rust compiler needed (modern packages):


# Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Needed for: cryptography, pydantic-core, etc.

  1. Pin to version with available wheel:


pip install numpy==1.26.2 # Check PyPI for available wheels

Revisions (0)

No revisions yet.