Python 3.15 on Docker: fix Failed building wheel for python-ldap, lz4, zstandard, h5py and ruamel.yaml.clib
Table of contents
- Key takeaways
- The exact pip install errors on python:3.15-slim
- Why does pip install fail on Python 3.15?
- Which Debian packages each one needs
- Failed building wheel for lz4
- Failed to build 'zstandard' when getting requirements to build wheel
- Failed building wheel for ruamel.yaml.clib
- Failed building wheel for python-ldap
- Failed building wheel for h5py
- A multi-stage Dockerfile that installs all five on python:3.15-slim
- Gotchas I ran into
- Alternatives: Python 3.14, Alpine or the full image
- No matching distribution found for onnxruntime is not this error
- Frequently asked questions
- When will these packages have wheels for Python 3.15?
- Is the error different on amd64 and arm64?
- Does build-essential work instead of gcc and libc6-dev?
- Conclusion
- Sources
On python:3.15-slim, pip install of python-ldap, lz4, zstandard, h5py or ruamel.yaml.clib ends with Failed building wheel for because none of them ships cp315 wheels and the image has no compiler. Install gcc, libc6-dev and each package's headers in a build stage, or use python:3.14-slim, which fixes four of the five.
If pip install ends with ERROR: Failed building wheel for on python:3.15-slim, the cause is that the package ships no cp315 wheels: pip downloads the source, tries to compile it, and the image has neither gcc nor the C headers. The fix is to install gcc, libc6-dev and each package's headers in a build stage, or to go back to python:3.14-slim. I reproduced it on 22 November 2026 with python-ldap, lz4, zstandard, h5py and ruamel.yaml.clib, on Linux arm64 and amd64, with Docker 29.5.2, Python 3.15.2 and pip 26.2.2. There is a Spanish version of this guide.
Key takeaways
- As of 3 December 2026, python-ldap 3.4.8, lz4 4.4.5, zstandard 0.25.0, h5py 3.16.0 and ruamel.yaml.clib 0.2.15 have 0
cp315wheels on PyPI. - lz4, zstandard and ruamel.yaml.clib build with
gccandlibc6-dev, with no other libraries. - python-ldap also needs
libldap2-devandlibsasl2-dev; h5py needspkg-configandlibhdf5-dev. - The multi-stage image with all five packages is 404 MB; with the compiler left inside, 840 MB.
python:3.14-sliminstalls four of the five from wheels. python-ldap fails there too because it has never shipped wheels.
The exact pip install errors on python:3.15-slim
The common symptom is the line ERROR: Failed building wheel for followed by the package name. This is what pip install lz4 prints on python:3.15-slim, minus the setuptools warnings:
error: [Errno 2] No such file or directory: 'gcc'
[end of output]
note: This error originates from a subprocess, and is likely not a
problem with pip.
ERROR: Failed building wheel for lz4
Failed to build lz4
error: failed-wheel-build-for-install
× Failed to build installable wheels for some pyproject.toml based projects
╰─> lz4
The line that explains the failure is the first one, and it changes with the package. These are the variants I got from the five:
error: [Errno 2] No such file or directory: 'gcc'
FileNotFoundError: [Errno 2] No such file or directory: 'gcc'
ERROR: Failed to build 'zstandard' when getting requirements to build wheel
error: pkg-config probably not installed: FileNotFoundError(2, 'No such file
or directory')
ERROR: Failed building wheel for python-ldap
ERROR: Failed building wheel for h5py
ERROR: Failed building wheel for ruamel.yaml.clib
With pip wheel instead of pip install, the last line is ERROR: Failed to build one or more wheels. On amd64 I got the same messages, with x86_64 instead of aarch64 in the paths.
Why does pip install fail on Python 3.15?
It fails because pip finds no prebuilt wheel for Python 3.15 and falls back to the source distribution, which needs a C compiler. The python:slim and python:3.15-slim tags point to the same image digest, so a FROM python:slim already builds on 3.15. I queried the files of each package's latest release through the PyPI (Python Package Index) API:
| Package | Version | Files on PyPI | Newest wheel |
|---|---|---|---|
| python-ldap | 3.4.8 | 1 (source only) | none |
| lz4 | 4.4.5 | 57 | cp314 |
| zstandard | 0.25.0 | 99 | cp314 |
| h5py | 3.16.0 | 48 | cp314 |
| ruamel.yaml.clib | 0.2.15 | 61 | cp314 |
The requests are still open in the repositories: python-lz4 issue #348[1], python-zstandard issue #354[2] and h5py issue #2993[3]. python-ldap is a different case. Its installation guide[4] says: "We do not currently provide pre-built packages (wheels)".
That is why python-ldap compiles on every Python version and the error is not new in 3.15. The rest of the release is covered in the summary of what is new in Python 3.15. PyYAML has shipped cp315 wheels since 6.0.4, released on 20 November 2026; if you pin an older version, see the guide to PyYAML on Python 3.15 in Docker.
Which Debian packages each one needs
Each package needs a compiler to build and, in two cases, a system library to run. python:3.15-slim is based on Debian 13, and these are the apt packages each one built and imported with in my tests:
| Python package | To build | To run |
|---|---|---|
| lz4 | gcc libc6-dev |
nothing |
| zstandard | gcc libc6-dev |
nothing |
| ruamel.yaml.clib | gcc libc6-dev |
nothing |
| python-ldap | gcc libc6-dev libldap2-dev libsasl2-dev |
libldap2 libsasl2-2 |
| h5py | gcc libc6-dev pkg-config libhdf5-dev |
libhdf5-310 libhdf5-hl-310 |
With --no-install-recommends, gcc and libc6-dev add up to 35 packages and 205 MB. build-essential also works for the first three, but it installs 51 packages and 323 MB.
Failed building wheel for lz4
lz4 fails while compiling its first extension because it cannot find the compiler:
building 'lz4._version' extension
error: [Errno 2] No such file or directory: 'gcc'
ERROR: Failed building wheel for lz4
lz4 4.4.5 bundles the library source in its own package, so it needs no system headers. With gcc and libc6-dev, pip built lz4-4.4.5-cp315-cp315-linux_aarch64.whl, 1.2 MB, and the final image needs no extra package.
Failed to build 'zstandard' when getting requirements to build wheel
zstandard fails one step earlier than the others, which is why the message differs:
File "/tmp/pip-install-…/zstandard_…/make_cffi.py", line 139, in preprocess
process = subprocess.Popen(
FileNotFoundError: [Errno 2] No such file or directory: 'gcc'
ERROR: Failed to build 'zstandard' when getting requirements to build wheel
Its setup.py runs gcc as a preprocessor while pip works out the build requirements, before anything is built. The fix is the same as for lz4: gcc and libc6-dev. The resulting wheel is 4.9 MB and zstandard.backend returns cext, the C variant.
Failed building wheel for ruamel.yaml.clib
ruamel.yaml.clib fails the same way as lz4, while compiling the _ruamel_yaml extension:
building '_ruamel_yaml' extension
error: [Errno 2] No such file or directory: 'gcc'
ERROR: Failed building wheel for ruamel.yaml.clib
gcc and libc6-dev fix it, but first check whether you need the package. pip install ruamel.yaml installed 0.19.1 on python:3.15-slim without compiling anything, because that release only asks for ruamel.yaml.clib through the oldlibyaml extra.
The error appears when the package is listed by name in requirements.txt. That is the case of a file generated with pip freeze on an earlier Python version, where ruamel.yaml 0.18.17 declares it as a dependency under python_version < "3.15". If that is your case, delete the line and regenerate the file.
Failed building wheel for python-ldap
python-ldap links against OpenLDAP, the client library for LDAP (Lightweight Directory Access Protocol), and against Cyrus SASL (Simple Authentication and Security Layer). The error changes three times depending on what you have installed:
error: [Errno 2] No such file or directory: 'gcc'
Modules/common.h:15:10: fatal error: lber.h: No such file or directory
Modules/LDAPObject.c:16:10: fatal error: sasl/sasl.h: No such file or
directory
ERROR: Failed building wheel for python-ldap
The first line appears with no compiler, the second with gcc but without libldap2-dev, and the third when libsasl2-dev is missing. With the four packages in the table it built, and ldap.SASL_AVAIL and ldap.TLS_AVAIL returned 1. The final image needs libldap2 and libsasl2-2, or import ldap fails with ImportError: libldap.so.2: cannot open shared object file.
python-ldap issue #692[5] asks for official 3.15 support and is still open, with 9 comments. Even so, 3.4.8 built and created an LDAP client in my tests.
Failed building wheel for h5py
h5py is the interface to HDF5 (Hierarchical Data Format 5) and needs the system library, which it locates with pkg-config. Without it, this is the error:
Building h5py requires pkg-config unless the HDF5 path is explicitly
specified using the environment variable HDF5_DIR.
error: pkg-config probably not installed: FileNotFoundError(2, 'No such file
or directory')
ERROR: Failed building wheel for h5py
With pkg-config installed and no HDF5, the message becomes error: Unable to load dependency HDF5, make sure HDF5 is installed properly, followed by error: libhdf5.so: cannot open shared object file. With libhdf5-dev, pip built a 9.3 MB wheel linked against HDF5 1.14.5. NumPy is not a problem: h5py depends on it and pip downloaded the cp315 wheel of numpy 2.5.5.
The h5py installation documentation[6] recommends prebuilt wheels, so compiling is a workaround until the release that issue #2993 asks for is published.
A multi-stage Dockerfile that installs all five on python:3.15-slim
A multi-stage image compiles the wheels in a stage that has gcc and installs them in another that only has the runtime libraries. This is the Dockerfile I built, with the five packages pinned in requirements.txt:
FROM python:3.15-slim AS build
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc libc6-dev pkg-config \
libldap2-dev libsasl2-dev libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
FROM python:3.15-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libldap2 libsasl2-2 libhdf5-310 libhdf5-hl-310 \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN --mount=type=bind,from=build,source=/wheels,target=/wheels \
pip install --no-cache-dir --no-index --find-links /wheels \
-r requirements.txt
pip wheel leaves in /wheels the five compiled wheels and those of their dependencies (numpy, pyasn1 and pyasn1_modules). The --no-index option forces pip to use those wheels and to fail if one is missing, instead of compiling again. The --mount=type=bind mount avoids copying the wheels into a layer of the final image. Remove from both apt lists what you do not use: if you only install lz4 or zstandard, the second stage needs no package at all.
To verify the image, import each module and run a real operation. This was the output of my check, which compresses and decompresses with lz4 and zstandard, writes an HDF5 file and creates an LDAP client:
python 3.15.2
python-ldap 3.4.8 SASL 1 TLS 1
lz4 4.4.5
zstandard 0.25.0 backend cext
h5py 3.16.0 HDF5 1.14.5
The same Dockerfile built and passed the check on amd64. Leaving the compiler in the final image doubles its size:
Gotchas I ran into
Three failures showed up after installing the compiler, and none of them names the real cause:
gccwithoutlibc6-dev: with--no-install-recommends,aptinstallsgccwithout the C headers and the four packages I tried fail withPython.h:21:10: fatal error: assert.h: No such file or directory.- Runtime libraries:
pip installsucceeds in the final image and the failure comes at import time. Withoutlibhdf5-hl-310, h5py fails withImportError: libhdf5_serial_hl.so.310: cannot open shared object file. - Full image:
python:3.15hasgccand built lz4, zstandard and ruamel.yaml.clib, but python-ldap failed onsasl/sasl.hand h5py onUnable to load dependency HDF5.
Alternatives: Python 3.14, Alpine or the full image
If you need nothing from 3.15, pinning python:3.14-slim is the shortest change. On that image (Python 3.14.10), pip downloaded cp314 wheels of lz4, zstandard, h5py and ruamel.yaml.clib, and only python-ldap kept failing with No such file or directory: 'gcc'.
On python:3.15-alpine (Alpine 3.24.4) the five fail with the same messages. They installed after this command, although import h5py printed an HDF5 version warning that does not stop it from working:
apk add --no-cache build-base pkgconf openldap-dev hdf5-dev
The full python:3.15 image is 1.64 GB and only fixes three of the five, so I do not recommend it here. If you are choosing a base, the comparison of Wolfi, Alpine and distroless measures sizes and vulnerabilities with the same application.
No matching distribution found for onnxruntime is not this error
If the message is ERROR: No matching distribution found for, installing a compiler changes nothing. onnxruntime 1.32.0 and tensorflow 2.22.0, released on 30 November 2026, publish no source distribution on PyPI, and the wheels of both stop at cp314. On python:3.15-slim, pip answers:
ERROR: Could not find a version that satisfies the requirement onnxruntime
(from versions: none)
ERROR: No matching distribution found for onnxruntime
The only way out today is an earlier Python version. The same message is useful to catch the problem in continuous integration: pip install --only-binary=:all: lz4 answered No matching distribution found for lz4 instead of trying to compile.
Frequently asked questions
When will these packages have wheels for Python 3.15?
No date has been published. As of 3 December 2026, the lz4, zstandard and h5py issues are still open, and python-ldap ships no wheels for any version. To check, open the package's files tab on PyPI and look for cp315 in the file names. Once it appears, pip install will download the wheel and you can drop the build stage.
Is the error different on amd64 and arm64?
No. I repeated the installs with --platform linux/amd64 and the five packages failed with the same messages, because there are no cp315 wheels for any architecture. The multi-stage Dockerfile also built on amd64 with the same Debian packages.
Does build-essential work instead of gcc and libc6-dev?
Yes for lz4, zstandard and ruamel.yaml.clib: with build-essential the three installed. It adds g++, make and dpkg-dev, which these packages do not use, and takes 323 MB against 205 MB. python-ldap and h5py also need their headers.
Conclusion
The error has a single cause, the missing cp315 wheels, and the fix depends on each package's libraries. For lz4, zstandard and ruamel.yaml.clib, add gcc and libc6-dev to a build stage. For python-ldap and h5py, add their headers at build time and their libraries in the final image. Before you ship the image, import each module: a clean pip install does not guarantee that the system library is present.
Sources: [1] lz4 4.4.5 files on PyPI[7], [2] zstandard 0.25.0 files on PyPI[8], [3] h5py 3.16.0 files on PyPI[9], [4] python-ldap installation guide[4], [5] h5py installation documentation[6], [6] python-ldap, issue #692: Add support for Python 3.15[5], [7] h5py, issue #2993 on the release for Python 3.15[3], [8] python-lz4, issue #348: Python 3.15(t) support[1], [9] python-zstandard, issue #354: Python 3.15 wheels[2], [10] ruamel.yaml 0.19.1 metadata on PyPI[10].
Sources
Source code
Access all the source code for this post on GitHub.
View on GitHub