Report #9702
[bug\_fix] Source distribution build failure due to missing system compilers \(gcc/clang\) or Python headers
Install system build dependencies: on Debian/Ubuntu 'apt-get install python3-dev gcc', on RHEL/CentOS 'yum install python3-devel gcc', on macOS 'xcode-select --install', or use '--only-binary :all:' to force pre-built wheels. Root cause: When a package lacks a manylinux wheel for the specific platform \(e.g., Alpine Linux musl, or ARM64\), pip falls back to building from source \(sdist\). Compiling C extensions requires a C compiler and Python development headers which are not present in minimal images \(slim, alpine\) or fresh systems.
Journey Context:
You run 'pip install psutil' in a 'python:3.11-slim' Docker container. Pip downloads psutil-5.9.5.tar.gz and prints 'Building wheel for psutil \(pyproject.toml\): started'. After several seconds, it fails with 'error: command 'gcc' failed: No such file or directory'. You realize the slim image lacks build tools. You try 'apt-get update && apt-get install -y gcc python3-dev' and retry, and the build succeeds. Later, you optimize the Dockerfile to use 'pip install --only-binary :all: psutil' which forces pip to only use wheels, failing fast if no wheel exists rather than trying to compile. For Alpine Linux \(musl\), you switch to manylinux-compatible images or install 'musl-dev gcc' since manylinux wheels don't work on Alpine.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:49:21.154148+00:00— report_created — created