Installation

Warnings

Warning

Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.

Warning

Pillow >= 1.0 no longer supports “import Image”. Please use “from PIL import Image” instead.

Warning

Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.

Notes

Note

Pillow is supported on the following Python versions

Python3.83.73.63.53.43.33.22.72.62.52.4
Pillow >= 7YesYesYesYes
Pillow 6.2.1 - 6.2.2YesYesYesYes Yes
Pillow 6.0 - 6.2.0 YesYesYes Yes
Pillow 5.2 - 5.4 YesYesYesYes Yes
Pillow 5.0 - 5.1 YesYesYes Yes
Pillow 4 YesYesYesYes Yes
Pillow 2 - 3 YesYesYesYesYesYes
Pillow < 2 YesYesYesYes

Basic Installation

Note

The following instructions will install Pillow with support formost common image formats. See External Libraries for afull list of external libraries supported.

Install Pillow with pip:

  1. python3 -m pip install --upgrade pip
  2. python3 -m pip install --upgrade Pillow

Windows Installation

We provide Pillow binaries for Windows compiled for the matrix ofsupported Pythons in both 32 and 64-bit versions in the wheel format.These binaries have all of the optional libraries included exceptfor raqm, libimagequant, and libxcb:

  1. python3 -m pip install --upgrade pip
  2. python3 -m pip install --upgrade Pillow

macOS Installation

We provide binaries for macOS for each of the supported Pythonversions in the wheel format. These include support for all optionallibraries except libimagequant and libxcb. Raqm support requireslibraqm, fribidi, and harfbuzz to be installed separately:

  1. python3 -m pip install --upgrade pip
  2. python3 -m pip install --upgrade Pillow

Linux Installation

We provide binaries for Linux for each of the supported Pythonversions in the manylinux wheel format. These include support for alloptional libraries except libimagequant. Raqm support requireslibraqm, fribidi, and harfbuzz to be installed separately:

  1. python3 -m pip install --upgrade pip
  2. python3 -m pip install --upgrade Pillow

Most major Linux distributions, including Fedora, Debian/Ubuntu andArchLinux also include Pillow in packages that previously containedPIL e.g. python-imaging.

FreeBSD Installation

Pillow can be installed on FreeBSD via the official Ports or Packages systems:

Ports:

  1. cd /usr/ports/graphics/py-pillow && make install clean

Packages:

  1. pkg install py36-pillow

Note

The Pillow FreeBSD port and packagesare tested by the ports team with all supported FreeBSD versions.

Building From Source

Download and extract the compressed archive from PyPI.

External Libraries

Note

You do not need to install all supported external libraries touse Pillow’s basic features. Zlib and libjpeg are requiredby default.

Note

There are Dockerfiles in our Docker images repo to install thedependencies for some operating systems.

Many of Pillow’s features require external libraries:

  • libjpeg provides JPEG functionality.
    • Pillow has been tested with libjpeg versions 6b, 8, 9-9d andlibjpeg-turbo version 8.
    • Starting with Pillow 3.0.0, libjpeg is required by default, butmay be disabled with the —disable-jpeg flag.
  • zlib provides access to compressed PNGs
    • Starting with Pillow 3.0.0, zlib is required by default, but maybe disabled with the —disable-zlib flag.
  • libtiff provides compressed TIFF functionality
    • Pillow has been tested with libtiff versions 3.x and 4.0-4.1
  • libfreetype provides type related services
  • littlecms provides color management
    • Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 andabove uses liblcms2. Tested with 1.19 and 2.7-2.9.
  • libwebp provides the WebP format.
    • Pillow has been tested with version 0.1.3, which does not readtransparent WebP files. Versions 0.3.0 and above supporttransparency.
  • tcl/tk provides support for tkinter bitmap and photo images.
  • openjpeg provides JPEG 2000 functionality.
    • Pillow has been tested with openjpeg 2.0.0, 2.1.0 and 2.3.1.
    • Pillow does not support the earlier 1.5 series which shipswith Debian Jessie.
  • libimagequant provides improved color quantization
    • Pillow has been tested with libimagequant 2.6-2.12.6
    • Libimagequant is licensed GPLv3, which is more restrictive thanthe Pillow license, therefore we will not be distributing binarieswith libimagequant support enabled.
  • libraqm provides complex text layout support.
    • libraqm provides bidirectional text support (using FriBiDi),shaping (using HarfBuzz), and proper script itemization. As aresult, Raqm can support most writing systems covered by Unicode.
    • libraqm depends on the following libraries: FreeType, HarfBuzz,FriBiDi, make sure that you install them before installing libraqmif not available as package in your system.
    • setting text direction or font features is not supported withoutlibraqm.
    • libraqm is dynamically loaded in Pillow 5.0.0 and above, so supportis available if all the libraries are installed.
    • Windows support: Raqm is not included in prebuilt wheels
  • libxcb provides X11 screengrab support.

Once you have installed the prerequisites, run:

  1. python3 -m pip install --upgrade pip
  2. python3 -m pip install --upgrade Pillow

If the prerequisites are installed in the standard library locationsfor your machine (e.g. /usr or /usr/local), noadditional configuration should be required. If they are installed ina non-standard location, you may need to configure setuptools to usethose locations by editing setup.py orsetup.cfg, or by adding environment variables on the commandline:

  1. CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow

If Pillow has been previously built without the requiredprerequisites, it may be necessary to manually clear the pip cache orbuild without cache using the —no-cache-dir option to force abuild with newly installed external libraries.

Build Options

  • Environment variable: MAX_CONCURRENCY=n. Pillow can usemultiprocessing to build the extension. Setting MAX_CONCURRENCYsets the number of CPUs to use, or can disable parallel building byusing a setting of 1. By default, it uses 4 CPUs, or if 4 are notavailable, as many as are present.
  • Build flags: —disable-zlib, —disable-jpeg,—disable-tiff, —disable-freetype, —disable-lcms,—disable-webp, —disable-webpmux, —disable-jpeg2000,—disable-imagequant, —disable-xcb.Disable building the corresponding feature even if the developmentlibraries are present on the building machine.
  • Build flags: —enable-zlib, —enable-jpeg,—enable-tiff, —enable-freetype, —enable-lcms,—enable-webp, —enable-webpmux, —enable-jpeg2000,—enable-imagequant, —enable-xcb.Require that the corresponding feature is built. The build will raisean exception if the libraries are not found. Webpmux (WebP metadata)relies on WebP support. Tcl and Tk also must be used together.
  • Build flag: —disable-platform-guessing. Skips all of theplatform dependent guessing of include and library directories forautomated build systems that configure the proper paths in theenvironment variables (e.g. Buildroot).
  • Build flag: —debug. Adds a debugging flag to the include andlibrary search process to dump all paths searched for and found tostdout.

Sample usage:

  1. MAX_CONCURRENCY=1 python3 setup.py build_ext --enable-[feature] install

or using pip:

  1. python3 -m pip install --upgrade Pillow --global-option="build_ext" --global-option="--enable-[feature]"

Building on macOS

The Xcode command line tools are required to compile portions ofPillow. The tools are installed by running xcode-select —installfrom the command line. The command line tools are required even if youhave the full Xcode package installed. It may be necessary to runsudo xcodebuild -license to accept the license prior to using thetools.

The easiest way to install external libraries is via Homebrew. After you install Homebrew, run:

  1. brew install libtiff libjpeg webp little-cms2

To install libraqm on macOS use Homebrew to install its dependencies:

  1. brew install freetype harfbuzz fribidi

Then see depends/install_raqm_cmake.sh to install libraqm.

Now install Pillow with:

  1. python3 -m pip install --upgrade pip
  2. python3 -m pip install --upgrade Pillow

or from within the uncompressed source directory:

  1. python3 setup.py install

Building on Windows

We don’t recommend trying to build on Windows. It is a maze of twistypassages, mostly dead ends. There are build scripts and notes for theWindows build in the winbuild directory.

Building on FreeBSD

Note

Only FreeBSD 10 and 11 tested

Make sure you have Python’s development libraries installed:

  1. sudo pkg install python3

Prerequisites are installed on FreeBSD 10 or 11 with:

  1. sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb

Then see depends/install_raqm_cmake.sh to install libraqm.

Building on Linux

If you didn’t build Python from source, make sure you have Python’sdevelopment libraries installed.

In Debian or Ubuntu:

  1. sudo apt-get install python3-dev python3-setuptools

In Fedora, the command is:

  1. sudo dnf install python3-devel redhat-rpm-config

Note

redhat-rpm-config is required on Fedora 23, but not earlier versions.

Prerequisites are installed on Ubuntu 16.04 LTS with:

  1. sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
  2. libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
  3. libharfbuzz-dev libfribidi-dev libxcb1-dev

Then see depends/install_raqm.sh to install libraqm.

Prerequisites are installed on recent RedHat Centos or Fedora with:

  1. sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
  2. freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
  3. harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel

Note that the package manager may be yum or dnf, depending on theexact distribution.

See also the Dockerfiles in the Test Infrastructure repo(https://github.com/python-pillow/docker-images) for a known workinginstall process for other tested distros.

Building on Android

Basic Android support has been added for compilation within the Termuxenvironment. The dependencies can be installed by:

  1. pkg install -y python ndk-sysroot clang make \
  2. libjpeg-turbo

This has been tested within the Termux app on ChromeOS, on x86.

Platform Support

Current platform support for Pillow. Binary distributions arecontributed for each release on a volunteer basis, but the sourceshould compile and run everywhere platform support is listed. Ingeneral, we aim to support all current versions of Linux, macOS, andWindows.

Continuous Integration Targets

These platforms are built and tested for every change.

Operating systemTested Python versionsTested architecture
Alpine3.8x86-64
Arch3.8x86-64
Amazon Linux 13.6x86-64
Amazon Linux 23.7x86-64
CentOS 63.6x86-64
CentOS 73.6x86-64
CentOS 83.6x86-64
Debian 9 Stretch3.5x86
Debian 10 Buster3.7x86
Fedora 303.7x86-64
Fedora 313.7x86-64
macOS 10.15 Catalina3.5, 3.6, 3.7, 3.8, PyPy3x86-64
Ubuntu Linux 16.04 LTS3.5, 3.6, 3.7, 3.8, PyPy3x86-64
Windows Server 2012 R23.5, 3.8x86, x86-64
PyPy3, 3.7/MinGWx86
Windows Server 20193.5, 3.6, 3.7, 3.8x86, x86-64
PyPy3x86

Other Platforms

These platforms have been reported to work at the versions mentioned.

Note

Contributors please test Pillow on your platform then update thisdocument and send a pull request.

Operating systemTested Python versionsLatest tested Pillow versionTested processors
macOS 10.15 Catalina3.5, 3.6, 3.7, 3.87.0.0x86-64
macOS 10.14 Mojave2.7, 3.5, 3.6, 3.76.0.0x86-64
3.45.4.1
macOS 10.13 High Sierra2.7, 3.4, 3.5, 3.64.2.1x86-64
macOS 10.12 Sierra2.7, 3.4, 3.5, 3.64.1.1x86-64
Mac OS X 10.11 El Capitan2.7, 3.4, 3.5, 3.6, 3.75.4.1x86-64
3.34.1.0
Mac OS X 10.9 Mavericks2.7, 3.2, 3.3, 3.43.0.0x86-64
Mac OS X 10.8 Mountain Lion2.6, 2.7, 3.2, 3.3 x86-64
Redhat Linux 62.6 x86
CentOS 6.32.7, 3.3 x86
Fedora 232.7, 3.43.1.0x86-64
Ubuntu Linux 12.04 LTS2.6, 3.2, 3.3, 3.4, 3.5PyPy5.3.1, PyPy3 v2.4.03.4.1x86,x86-64
2.74.3.0x86-64
2.7, 3.23.4.1ppc
Ubuntu Linux 10.04 LTS2.62.3.0x86,x86-64
Debian 8.2 Jessie2.7, 3.43.1.0x86-64
Raspbian Jessie2.7, 3.43.1.0arm
Raspbian Stretch2.7, 3.54.0.0arm
Gentoo Linux2.7, 3.22.1.0x86-64
FreeBSD 11.12.7, 3.4, 3.5, 3.64.3.0x86-64
FreeBSD 10.32.7, 3.4, 3.54.2.0x86-64
FreeBSD 10.22.7, 3.43.1.0x86-64
Windows 8.1 Pro2.6, 2.7, 3.2, 3.3, 3.42.4.0x86,x86-64
Windows 8 Pro2.6, 2.7, 3.2, 3.3, 3.4a32.2.0x86,x86-64
Windows 7 Pro2.7, 3.2, 3.33.4.1x86-64
Windows Server 2008 R2 Enterprise3.3 x86-64

Old Versions

You can download old distributions from the release history at PyPI and by direct URL accesseg. https://pypi.org/project/Pillow/1.0/.