Main Ecosystems
HomePython CorePandas ReferenceNumPy ScientificFastAPI & PydanticDjango Enterprise
More Ecosystems
Environment & SetupRequests & HTTPAsyncIO ConcurrencyObject-Oriented OOPPyTorch Deep LearningScikit-Learn MLFlask FrameworkWeb ScrapingDatabase & ORMDevOps & Docker

Failed Building Wheel for Pillow on Windows

Verified FixPython 3.10+Pillow 10.2+Silo: environment

Quick Fix / Solution Rapide

Upgrade pip (python -m pip install --upgrade pip) to automatically download official pre-compiled .whl binaries for Windows.

Root Cause Analysis

This error occurs when pip install pillow on Windows fails because pip attempts to compile Pillow from source (.tar.gz), and the Windows machine lacks the Microsoft Visual C++ compiler or native image development libraries (libjpeg, zlib, libpng).

1. Outdated Pip Lacking Wheel Compatibility Tags

Pillow maintainers publish official, pre-compiled binary wheels for all supported Windows versions and Python architectures on PyPI. If pip is outdated, it fails to recognize the matching .whl file and attempts a source build.

2. Missing MSVC Build Tools on Windows

Building Pillow from source requires Microsoft C++ Build Tools (MSVC v143+) along with external C libraries that are not bundled in the source tarball.

3. Brand New Python Releases

Installing Pillow on unreleased or brand new Python versions before Pillow wheels are uploaded to PyPI forces a source compilation.

4. Unsupported 32-bit Python on 64-bit Windows

Accidentally installing 32-bit (x86) Python on a 64-bit Windows OS may cause wheel matching mismatches.

Reproduction Code (MCVE)

Example: Bug Reproduction
# **Note de reproductibilité :** Dépendant de l'environnement Windows.
raise OSError('ERROR: Failed building wheel for pillow. Running setup.py bdist_wheel did not run successfully on Windows (MSVC cl.exe not found)')

Solution 1: Upgrade Pip and Force Pre-Compiled Binary Wheel

Upgrade pip so it automatically fetches the pre-built .whl binary for your exact Python version and architecture.

Example: Recommended Solution
import sys

print(f'Python version: {sys.version}')
print('Execute in PowerShell:')
print('python -m pip install --upgrade pip setuptools wheel')
print('python -m pip install pillow --only-binary :all:')

Solution 2: Install Microsoft C++ Build Tools

If compiling from source is mandatory, install the Visual Studio Build Tools with Desktop development with C++.

Example: Alternative Solution
print('Download Build Tools:')
print('https://visualstudio.microsoft.com/visual-cpp-build-tools/')
print('Select: Desktop development with C++')

A common mistake is installing pip install PIL. The original PIL (Python Imaging Library) was discontinued in 2009. The modern, maintained library is Pillow. Always run pip install pillow, then from PIL import Image in Python code. Edge cases occur with custom image formats (HEIF, WebP): Pillow binary wheels include standard format support; specialized codecs require pillow-heif. Contrast this error with ImportError: DLL load failed while importing _imaging, which indicates missing runtime C runtime DLLs.