Short answer

python -m pip install pillow, inside a virtual environment, using the same python that will run your code. Then from PIL import Image. Pillow 13 supports Python 3.11 to 3.15, and ships ready-made wheels for Windows, macOS and Linux (including Alpine and ARM), so no compiler or system libraries are needed.

Pick the install command for your setup
  1. 1
    Starting a project?
    Yes: Create a virtual environment, activate it, then python -m pip install pillow. Details ↓
  2. 2
    Got error: externally-managed-environment?
    Yes: Your system Python is managed by the OS: use a virtual environment (or the distro package). Details ↓
  3. 3
    Using conda, Jupyter or Docker?
    Yes: Use conda install pillow, %pip install pillow in the notebook, or add it to the image. Details ↓
  4. ✓
    Check: python -c "import PIL; print(PIL.__version__)".

A virtual environment gives your project its own Python and its own packages, so nothing conflicts with the system or with other projects. We ran these three lines on a clean machine:

Terminal (macOS / Linux)
python -m venv .venv
.venv/bin/python -m pip install --quiet pillow
.venv/bin/python -c "import PIL; print('Pillow', PIL.__version__)"
Tested on ✓ Linux ✓ macOS (Linux and macOS-specific example)
Output
Pillow 13.0.0

On Windows the interpreter lives under Scripts instead of bin:

Command Prompt / PowerShell (Windows)
python -m venv .venv
.venv\Scripts\python -m pip install --quiet pillow
.venv\Scripts\python -c "import PIL; print('Pillow', PIL.__version__)"

After activating the environment (source .venv/bin/activate, or .venv\Scripts\activate on Windows), plain python and pip refer to it. Point your editor at the same interpreter: in VS Code, Python: Select Interpreter; in PyCharm, the project interpreter setting.

Why python -m pip and not pip

pip is a script that belongs to one particular Python. On machines with several Pythons (a system one, one from python.org, one from Homebrew or the Microsoft Store, Anaconda…), pip and python often point to different ones, so Pillow lands somewhere your code never looks. python -m pip always installs into the Python you name. The No module named 'PIL' page shows how to check which Python each command uses.

error: externally-managed-environment (Ubuntu, Debian, Homebrew)

Recent Linux distributions (Ubuntu 23.04 and later, Debian 12 and later) and Homebrew's Python mark their own interpreter as "externally managed" (PEP 668), so running pip against it is refused:

Terminal (Ubuntu 24.04, system Python)
/usr/bin/python3 -m pip install pillow

pip stops with error: externally-managed-environment and a hint about virtual environments. We tried to record the full message on GitHub's Ubuntu runners, but their images remove this protection, so pip installs there without complaint; on a normal Ubuntu desktop or server it refuses. The fix is the virtual environment above. Alternatives: sudo apt install python3-pil gives you the distribution's packaged Pillow, which is usually several versions behind; pipx is for command-line tools, not libraries. Avoid --break-system-packages: it can break system tools that depend on the distribution's packages.

pip install PIL fails

ERROR: Could not find a version that satisfies the requirement PIL: there is no installable package called PIL. The original PIL stopped at version 1.1.7 in 2009 and only ever supported Python 2 (PIL vs Pillow). Pillow is its maintained fork and the drop-in replacement. Install pillow (the name is not case-sensitive for pip), import PIL.

Conda, Jupyter, Docker

  • Conda / Anaconda: conda install -c conda-forge pillow. Anaconda's base environment usually has Pillow already. Don't install it with both conda and pip in one environment; that is a classic source of cannot import name '_imaging'.
  • Jupyter, JupyterLab, Colab: run %pip install pillow in a cell. The %pip magic installs into the kernel's Python, which is not necessarily the one your terminal uses. Restart the kernel after upgrading Pillow, because the old version stays loaded.
  • Docker: RUN pip install --no-cache-dir pillow in any official python image, including -slim and -alpine: wheels exist for both glibc and musl Linux. You only need apt/apk packages for fonts (for example fonts-dejavu-core) if you draw text with system fonts.

uv, Poetry, and Pillow together with NumPy, OpenCV or matplotlib

Terminal (uv)
python -m uv venv -q .venv                       # or just: uv venv .venv
python -m uv pip install -q --python .venv pillow
.venv/bin/python -c "import PIL; print('Pillow', PIL.__version__)"
Output
Pillow 13.0.0
  • uv: in a project, uv add pillow adds it to pyproject.toml and the lock file; outside one, uv pip install pillow works like pip, as above. It installs the same wheels from PyPI.
  • Poetry: poetry add pillow.
  • Several libraries at once: python -m pip install pillow numpy matplotlib opencv-python-headless. One command lets pip choose versions that work together. Use opencv-python-headless on servers and in Docker, since the plain opencv-python package also pulls in GUI libraries.
  • Pillow-SIMD is a faster fork that replaces Pillow rather than adding to it, and it trails Pillow's releases; see what Pillow-SIMD is before switching.

Check which version you have

check_version.py
import importlib.metadata
import sys

import PIL

print("Pillow", PIL.__version__)
print("same, from package metadata:", importlib.metadata.version("pillow"))
print("Python", sys.version.split()[0], "at", sys.executable)
Tested on ✓ Linux ✓ Windows ✓ macOS
Output
Pillow 13.0.0
same, from package metadata: 13.0.0
Python 3.13.17 at /home/you/.venv/bin/python

Upgrade with:

Terminal
python -m pip install --upgrade pillow

Major versions remove deprecated APIs: Pillow 10 removed Image.ANTIALIAS and ImageDraw.textsize(), for example (every major release is summarised in Pillow's versions and what they changed). Before upgrading an old project, run your tests with python -W error::DeprecationWarning to see what will break.

Which Pillow for which Python

PythonNewest Pillow that supports it
3.11 to 3.15Current Pillow 13
3.10Pillow 12.3
3.9Pillow 11.3
3.8Pillow 10.4
3.7Pillow 9.5
3.6Pillow 8.4
2.7Pillow 6.2.2

Checked against PyPI: for each Python version, the newest Pillow release that has a wheel for it. If pip on an older Python installs an old Pillow, this is why; upgrade Python rather than forcing a newer Pillow.

From the Pillow project's support table. pip picks the newest compatible version automatically, so on an old Python pip install pillow still works; it just installs an older release. If pip instead tries to build Pillow from source (you will see compiler output, or The headers or library files could not be found for jpeg), it found no wheel for your platform; see the next section.

Failed building wheel for Pillow

pip only compiles Pillow when it finds no ready-made wheel for your Python and platform. Without the C libraries' headers the build stops with this message (copied from Pillow 13's setup.py), followed by ERROR: Failed building wheel for pillow:

pip install pillow (building from source)
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.

JPEG and zlib are the two libraries Pillow refuses to build without. First find out why there was no wheel. Pillow 13.0.0 publishes wheels for these platforms (checked on PyPI):

PlatformWheelsCommon reason pip still builds
Windows64-bit, 32-bit and ARM64A Python newer than the release (a pre-release Python), or a very old pip
macOSIntel (10.10+) and Apple Silicon (11+)Old pip that does not know the tags
Linux, glibcx86_64 and aarch64, glibc 2.27 or newer (manylinux_2_28)An older system such as CentOS 7 or Amazon Linux 2 (glibc 2.17 and 2.26), or a 32-bit ARM board
Linux, musl (Alpine)x86_64 and aarch64pip older than 21.2, which does not know musllinux
Python versionCPython 3.11 to 3.15, PyPy 3.11 and 3.12Python 3.10 or older: pip falls back to an older Pillow, or builds it

So the fixes, in order:

  1. Upgrade pip (python -m pip install --upgrade pip) and try again. This fixes most cases on Alpine and on old virtual environments.
  2. Use a Python and platform with wheels: a released CPython 3.11–3.15, and a current base image (python:3.13-slim rather than an old CentOS or Amazon Linux 2 image).
  3. Raspberry Pi with 32-bit Raspberry Pi OS: there is no armv7 wheel on PyPI; Raspberry Pi OS already points pip at piwheels.org, which has prebuilt ones, or install the 64-bit OS.
  4. Otherwise install the build dependencies and let pip compile:
    • Debian, Ubuntu: sudo apt install build-essential python3-dev libjpeg-dev zlib1g-dev (add libfreetype6-dev for fonts and libwebp-dev, libtiff-dev for those formats)
    • Alpine: apk add build-base python3-dev jpeg-dev zlib-dev freetype-dev
    • Fedora, RHEL, Amazon Linux: sudo dnf install gcc python3-devel libjpeg-turbo-devel zlib-devel freetype-devel
    Optional libraries that are missing at build time are silently left out, so check the result with python -m PIL.report; a source build without FreeType cannot draw text with TrueType fonts.

Sources

What this page shows comes from running its code with Pillow 13.0.0. The API details and version history were checked against these primary sources:

The outputs and images on this page are the real results of running every example with Pillow 13.0.0 on Python 3.13 (Linux) on 2026-10-29. Every example is also re-run automatically on macOS (Darwin 25.6.0, Pillow 12.3.0), Linux (Linux 6.17.0-1022-azure, Pillow 12.3.0), Windows (Windows 2025Server, Pillow 12.3.0); the line under each example shows the result per operating system. The DejaVu Sans font files sit next to each script so font examples behave the same everywhere. Sample photos: NASA/Sam Lott, public domain. Spotted something wrong? Tell us.