ERROR REFERENCE
Binary validation failed: failed to build wheel
A dependency needed compiling and the build machine could not do it — no prebuilt wheel exists for this platform/Python combination, and building from source failed. Cryptography, numpy-adjacent, and database-driver packages are the usual suspects.
WHAT IT MEANS
What this error means
pip prefers prebuilt wheels; when none matches the target platform and Python version, it compiles from source — which needs compilers, headers, and sometimes Rust. CI runners and laptops often lack those, and even a successful local build can produce binaries that do not match Lambda's Linux runtime, which is the deeper reason SAM validates this step at all.
FIX
How to fix it
-
Build in the Lambda-matching container:
The build image ships the toolchain and produces Linux-correct binaries. This is the fix that removes the whole class.sam build --use-container - Or pin a version that ships a wheel for your runtime - newer releases of the failing package often added wheels for recent Python versions; check the package's PyPI files page.
- Align the Python version with what the package supports — a brand-new Python minor often lacks wheels for a few months, and downgrading the function runtime one minor is sometimes the pragmatic answer.
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor recognizes the wheel-build failure (high confidence) within the Python build family. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose build.log --format markdown
RELATED
Related errors
- PythonPipBuilder:ResolveDependencies failed — when no candidate version resolves at all.
- Cannot connect to the Docker daemon — the prerequisite for the --use-container fix.