debugpythonMajorpending
Debug: Python pip install fails with build errors
Viewed 0 times
pip-installbuild-errorgccwheelcompilationC-extension
Error Messages
Problem
pip install fails with compilation errors for packages that have C extensions (numpy, psycopg2, lxml, Pillow).
Solution
Fixes by common error type:
# macOS: xcode-select --install
# Ubuntu: sudo apt install build-essential
# Alpine: apk add gcc musl-dev
# 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
# Ubuntu: sudo apt install python3-dev
# Fedora: sudo dnf install python3-devel
pip install --prefer-binary <package>
# Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Needed for: cryptography, pydantic-core, etc.
pip install numpy==1.26.2 # Check PyPI for available wheels
- Missing C compiler:
# macOS: xcode-select --install
# Ubuntu: sudo apt install build-essential
# Alpine: apk add gcc musl-dev
- 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
- Python.h missing:
# Ubuntu: sudo apt install python3-dev
# Fedora: sudo dnf install python3-devel
- Use precompiled wheels when available:
pip install --prefer-binary <package>
- Rust compiler needed (modern packages):
# Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Needed for: cryptography, pydantic-core, etc.
- Pin to version with available wheel:
pip install numpy==1.26.2 # Check PyPI for available wheels
Revisions (0)
No revisions yet.