r/learnpython • • 11h ago

Error: failed building wheel for pillow

I'm trying to install marker-pdf and then hit with an error,

note: This error originates from a subprocess, and is likely not a problem with pip.

ERROR: Failed building wheel for pillow

Failed to build pillow

error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects

╰─> pillow

I've tried to upgrade pip, reinstalling setuptools, wheel, pillow, and none works, the error remains. What should I do?

OS: Arch Linux
Python: 3.14

7 Upvotes

6 comments sorted by

2

u/DimensionMost8342 10h ago

That error means pip found no prebuilt Pillow wheel for Python 3.14, so it fell back to compiling Pillow from source and the build died. On Arch the quickest fix is to skip pip for Pillow:

``

sudo pacman -S python-pillow pip install marker-pdf

If pip still builds from source, the version marker-pdf pins likely has no 3.14 wheel yet; a venv on Python 3.13 sidesteps it (uv venv -p 3.13 downloads one for you). Source builds also need zlib and libjpeg-turbo, which Arch already ships.

2

u/Riikq_ 10h ago

This has been very helpful! I didnt know about uv before, thank you so much. I hope you have a good day

3

u/Financial_Morning386 11h ago

The key detail here is Python 3.14. Upgrading pip, setuptools, and wheel will not fix this by itself, because the last lines are only the summary, not the cause.

When pip cannot find a prebuilt wheel for your Python version and platform, it falls back to building Pillow from source. That build needs a C compiler and the development headers for the libraries Pillow wraps, especially libjpeg and zlib. If any of those are missing, the build fails with exactly this kind of "failed building wheel" message. On Arch, that usually means installing the build toolchain and those libraries first, for example base-devel, libjpeg-turbo, and zlib, then trying again in a fresh virtual environment rather than the system Python.

The quickest workaround is often to use an older Python where a prebuilt Pillow wheel is available, such as Python 3.12 or 3.13, create a new venv with that interpreter, and install marker-pdf there. That avoids the source build entirely.

If you want to stay on Python 3.14, run the Pillow install verbosely in a clean venv:

python -m venv .venv
source .venv/bin/activate
pip install -v pillow

Then look well above the "Failed to build pillow" lines for the first error. It is usually something like a missing Python.h, jpeglib.h, or compiler error, and that first error tells you which package is actually missing. If you post that section, it will be much easier to pinpoint the fix.

1

u/a18618 10h ago

That failed building wheel line on its own never told me much either, because it just means the build fell over somewhere above it. When I hit the same wall on a fresh setup last year, reinstalling pip and the build tools did nothing, and the actual clue was buried a screen or two higher in the log, where the compiler complained about a missing piece. Could you paste the twenty or so lines right above the failure, so we can see whether yours is the same missing-library story or something else entirely?

1

u/gloslib 36m ago

Building pillow from PyPI is always a bit of a headache, if it doesn't have a prebuild.

If you're using the system python, which most people will do if they're using a linux distro, then doesn't it provide a prebuild for pillow in its repository? In my opinion, using the repository version is a no-brainer since the distro maintainers will have done the hard work of compilation and the testing against the system python for you.

What happens if you do the following?

sudo pacman -S python-pillow

(I'm not familiar with pacman myself because I'm using Kubuntu.)

1

u/acfot 1m ago

I hit this exact error when I was installing Pillow for a small project, and what fixed it for me was upgrading the build tools first before retrying the install. Try running pip install --upgrade pip setuptools wheel and then pip install Pillow again, because most of the time it fails while trying to build from source instead of grabbing a ready-made wheel. Also check that your Python version is actually supported by the Pillow version you're installing, since a version mismatch is the other common cause. If it still fails after that, paste the last few lines of the error — the real cause is usually buried right at the end, not in the first wall of red text.