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.
- 1Starting a project?Yes: Create a virtual environment, activate it, then
python -m pip install pillow. Details ↓ - 2Got
error: externally-managed-environment?Yes: Your system Python is managed by the OS: use a virtual environment (or the distro package). Details ↓ - 3Using conda, Jupyter or Docker?Yes: Use
conda install pillow,%pip install pillowin the notebook, or add it to the image. Details ↓ - ✓Check:
python -c "import PIL; print(PIL.__version__)".
Recommended: a virtual environment
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:
python -m venv .venv
.venv/bin/python -m pip install --quiet pillow
.venv/bin/python -c "import PIL; print('Pillow', PIL.__version__)"
Pillow 13.0.0
On Windows the interpreter lives under Scripts instead of bin:
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:
/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 pillowin a cell. The%pipmagic 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 pillowin any officialpythonimage, including-slimand-alpine: wheels exist for both glibc and musl Linux. You only needapt/apkpackages for fonts (for examplefonts-dejavu-core) if you draw text with system fonts.
uv, Poetry, and Pillow together with NumPy, OpenCV or matplotlib
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__)"
Pillow 13.0.0
- uv: in a project,
uv add pillowadds it topyproject.tomland the lock file; outside one,uv pip install pillowworks 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. Useopencv-python-headlesson servers and in Docker, since the plainopencv-pythonpackage 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
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)
Pillow 13.0.0
same, from package metadata: 13.0.0
Python 3.13.17 at /home/you/.venv/bin/python
Upgrade with:
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
| Python | Newest Pillow that supports it |
|---|---|
| 3.11 to 3.15 | Current Pillow 13 |
| 3.10 | Pillow 12.3 |
| 3.9 | Pillow 11.3 |
| 3.8 | Pillow 10.4 |
| 3.7 | Pillow 9.5 |
| 3.6 | Pillow 8.4 |
| 2.7 | Pillow 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:
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):
| Platform | Wheels | Common reason pip still builds |
|---|---|---|
| Windows | 64-bit, 32-bit and ARM64 | A Python newer than the release (a pre-release Python), or a very old pip |
| macOS | Intel (10.10+) and Apple Silicon (11+) | Old pip that does not know the tags |
| Linux, glibc | x86_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 aarch64 | pip older than 21.2, which does not know musllinux |
| Python version | CPython 3.11 to 3.15, PyPy 3.11 and 3.12 | Python 3.10 or older: pip falls back to an older Pillow, or builds it |
So the fixes, in order:
- Upgrade pip (
python -m pip install --upgrade pip) and try again. This fixes most cases on Alpine and on old virtual environments. - Use a Python and platform with wheels: a released CPython 3.11–3.15, and a current base image
(
python:3.13-slimrather than an old CentOS or Amazon Linux 2 image). - 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. - Otherwise install the build dependencies and let pip compile:
- Debian, Ubuntu:
sudo apt install build-essential python3-dev libjpeg-dev zlib1g-dev(addlibfreetype6-devfor fonts andlibwebp-dev,libtiff-devfor 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
python -m PIL.report; a source build without FreeType cannot draw text with TrueType fonts. - Debian, Ubuntu:
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:
- Pillow installation guide
- Pillow: Python version support
- Pillow: building from source
- PEP 668: externally managed environments
- Pillow on PyPI (releases and wheels)
Related
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.