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 12 supports Python 3.10 to 3.14, and ships ready-made wheels for Windows, macOS and Linux (including Alpine and ARM), so no compiler or system libraries are needed.

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 12.3.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. 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

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 12.3.0
same, from package metadata: 12.3.0
Python 3.13.16 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. 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.10 to 3.14Current Pillow 12
3.9Pillow 11
3.8Pillow 10.4
3.7Pillow 9.5
3.6Pillow 8.4
2.7Pillow 6.2.2

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: upgrade pip with python -m pip install --upgrade pip first, since old pip versions do not recognise newer wheel tags.

The outputs and images on this page are the real results of running every example with Pillow 12.3.0 on Python 3.13 (Linux) on 2026-10-15. 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.