Pillow/docs/installation.rst

395 lines
17 KiB
ReStructuredText
Raw Normal View History

Installation
============
2015-05-08 14:28:50 +03:00
Warnings
--------
.. warning:: Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.
2013-10-15 16:47:10 +04:00
.. 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.
2013-10-15 16:51:15 +04:00
2015-05-08 14:28:50 +03:00
Notes
-----
2013-10-15 16:51:15 +04:00
.. note:: Pillow < 2.0.0 supports Python versions 2.4, 2.5, 2.6, 2.7.
2013-10-15 16:48:52 +04:00
.. note:: Pillow >= 2.0.0 < 4.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
.. note:: Pillow >= 4.0.0 supports Python versions 2.7, 3.3, 3.4, 3.5, 3.6
Basic Installation
------------------
.. note::
2015-10-12 18:30:01 +03:00
The following instructions will install Pillow with support for
most common image formats. See :ref:`external-libraries` for a
full list of external libraries supported.
.. note::
2015-10-12 18:30:01 +03:00
2016-09-23 14:12:03 +03:00
The basic installation works on Windows and macOS using the binaries
2015-10-12 18:30:01 +03:00
from PyPI. Other installations require building from source as
detailed below.
2015-04-04 15:18:45 +03:00
Install Pillow with :command:`pip`::
$ pip install Pillow
2015-10-12 18:30:01 +03:00
Or use :command:`easy_install` for installing `Python Eggs
<http://peak.telecommunity.com/DevCenter/PythonEggs>`_ as
:command:`pip` does not support them::
$ easy_install Pillow
2015-10-12 18:30:01 +03:00
Windows Installation
^^^^^^^^^^^^^^^^^^^^
We provide Pillow binaries for Windows compiled for the matrix of
2015-10-14 11:25:20 +03:00
supported Pythons in both 32 and 64-bit versions in wheel, egg, and
2015-10-12 18:30:01 +03:00
executable installers. These binaries have all of the optional
libraries included::
> pip install Pillow
2015-10-12 18:30:01 +03:00
or::
> easy_install Pillow
2015-10-12 18:30:01 +03:00
2016-09-23 14:12:03 +03:00
macOS Installation
^^^^^^^^^^^^^^^^^^
2015-10-12 18:30:01 +03:00
2016-09-23 14:12:03 +03:00
We provide binaries for macOS for each of the supported Python versions
in the wheel format. These include support for all optional libraries
2015-10-12 18:30:01 +03:00
except OpenJPEG::
$ pip install Pillow
Linux Installation
^^^^^^^^^^^^^^^^^^
We do not provide binaries for Linux. Most major Linux distributions,
including Fedora, Debian/Ubuntu and ArchLinux include Pillow in
packages that previously contained PIL e.g. ``python-imaging``. Please
consider using native operating system packages first to avoid
installation problems and/or missing library support later.
FreeBSD Installation
^^^^^^^^^^^^^^^^^^^^
Pillow can be installed on FreeBSD via the official Ports or Packages systems:
**Ports**::
$ cd /usr/ports/graphics/py-pillow && make install clean
**Packages**::
$ pkg install py27-pillow
.. note::
The `Pillow FreeBSD port
<https://www.freshports.org/graphics/py-pillow/>`_ and packages
are tested by the ports team with all supported FreeBSD versions
and against Python 2.x and 3.x.
2015-10-12 18:30:01 +03:00
Building From Source
--------------------
Download and extract the `compressed archive from PyPI`_.
.. _compressed archive from PyPI: https://pypi.python.org/pypi/Pillow
.. _external-libraries:
2015-04-18 01:00:53 +03:00
External Libraries
2015-10-12 18:30:01 +03:00
^^^^^^^^^^^^^^^^^^
2014-07-04 23:17:23 +04:00
.. note::
2016-04-01 13:53:53 +03:00
You **do not need to install all supported external libraries** to
use Pillow's basic features. **Zlib** and **libjpeg** are required
by default.
2015-10-12 18:30:01 +03:00
.. note::
2015-10-12 18:30:01 +03:00
There are scripts to install the dependencies for some operating
systems included in the ``depends`` directory.
2014-07-04 23:17:23 +04:00
Many of Pillow's features require external libraries:
* **libjpeg** provides JPEG functionality.
* Pillow has been tested with libjpeg versions **6b**, **8**, **9**, **9a**,
and **9b** and libjpeg-turbo version **8**.
* Starting with Pillow 3.0.0, libjpeg is required by default, but
2015-10-02 12:09:13 +03:00
may 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 may
2015-10-02 12:09:13 +03:00
be disabled with the ``--disable-zlib`` flag.
2014-11-19 23:14:57 +03:00
* **libtiff** provides compressed TIFF functionality
* Pillow has been tested with libtiff versions **3.x** and **4.0**
* **libfreetype** provides type related services
* **littlecms** provides color management
2013-11-30 22:06:21 +04:00
* Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 and
2015-12-25 16:26:14 +03:00
above uses liblcms2. Tested with **1.19** and **2.7**.
2013-11-30 22:06:21 +04:00
2014-10-29 21:09:00 +03:00
* **libwebp** provides the WebP format.
2013-11-30 22:06:21 +04:00
* Pillow has been tested with version **0.1.3**, which does not read
2015-12-25 16:26:14 +03:00
transparent WebP files. Versions **0.3.0** and above support
2014-06-02 02:57:25 +04:00
transparency.
2014-06-02 02:57:25 +04:00
* **tcl/tk** provides support for tkinter bitmap and photo images.
2014-06-02 02:57:25 +04:00
* **openjpeg** provides JPEG 2000 functionality.
2014-06-02 23:22:45 +04:00
* Pillow has been tested with openjpeg **2.0.0** and **2.1.0**.
* Pillow does **not** support the earlier **1.5** series which ships
with Ubuntu and Debian.
2016-05-26 23:55:36 +03:00
* **libimagequant** provides improved color quantization
2016-05-26 23:55:36 +03:00
* Pillow has been tested with libimagequant **2.6.0**
2016-06-15 13:55:40 +03:00
* Libimagequant is licensed GPLv3, which is more restrictive than
2016-05-26 23:55:36 +03:00
the Pillow license, therefore we will not be distributing binaries
with libimagequant support enabled.
* Windows support: Libimagequant requires VS2013/MSVC 18 to compile,
so it is unlikely to work with any Python prior to 3.5 on Windows.
2015-10-12 18:30:01 +03:00
Once you have installed the prerequisites, run::
$ pip install Pillow
If the prerequisites are installed in the standard library locations
for your machine (e.g. :file:`/usr` or :file:`/usr/local`), no
additional configuration should be required. If they are installed in
a non-standard location, you may need to configure setuptools to use
those locations by editing :file:`setup.py` or
:file:`setup.cfg`, or by adding environment variables on the command
line::
$ CFLAGS="-I/usr/pkg/include" pip install pillow
2015-10-14 11:25:20 +03:00
If Pillow has been previously built without the required
2015-10-12 18:30:01 +03:00
prerequisites, it may be necessary to manually clear the pip cache or
build without cache using the ``--no-cache-dir`` option to force a
build with newly installed external libraries.
2014-11-19 23:14:57 +03:00
Build Options
2015-10-12 18:30:01 +03:00
^^^^^^^^^^^^^
2014-11-19 23:14:57 +03:00
* Environment variable: ``MAX_CONCURRENCY=n``. By default, Pillow will
2014-12-09 02:56:07 +03:00
use multiprocessing to build the extension on all available CPUs,
2014-12-08 22:15:44 +03:00
but not more than 4. Setting ``MAX_CONCURRENCY`` to 1 will disable
parallel building.
2014-11-19 23:14:57 +03:00
* Build flags: ``--disable-zlib``, ``--disable-jpeg``,
``--disable-tiff``, ``--disable-freetype``, ``--disable-tcl``,
``--disable-tk``, ``--disable-lcms``, ``--disable-webp``,
2016-05-06 20:26:41 +03:00
``--disable-webpmux``, ``--disable-jpeg2000``, ``--disable-imagequant``.
Disable building the corresponding feature even if the development
libraries are present on the building machine.
2014-11-19 23:14:57 +03:00
* Build flags: ``--enable-zlib``, ``--enable-jpeg``,
``--enable-tiff``, ``--enable-freetype``, ``--enable-tcl``,
``--enable-tk``, ``--enable-lcms``, ``--enable-webp``,
2016-05-06 20:26:41 +03:00
``--enable-webpmux``, ``--enable-jpeg2000``, ``--enable-imagequant``.
Require that the corresponding feature is built. The build will raise
an exception if the libraries are not found. Webpmux (WebP metadata)
relies on WebP support. Tcl and Tk also must be used together.
2014-11-19 23:14:57 +03:00
2016-05-01 13:03:44 +03:00
* Build flag: ``--disable-platform-guessing``. Skips all of the
platform dependent guessing of include and library directories for
automated build systems that configure the proper paths in the
environment variables (e.g. Buildroot).
* Build flag: ``--debug``. Adds a debugging flag to the include and
2016-04-09 18:15:24 +03:00
library search process to dump all paths searched for and found to
stdout.
Sample usage::
2014-11-19 23:14:57 +03:00
$ MAX_CONCURRENCY=1 python setup.py build_ext --enable-[feature] install
2014-11-19 23:14:57 +03:00
or using pip::
$ pip install pillow --global-option="build_ext" --global-option="--enable-[feature]"
2016-09-23 14:12:03 +03:00
Building on macOS
^^^^^^^^^^^^^^^^^
The Xcode command line tools are required to compile portions of
2016-07-01 14:17:51 +03:00
Pillow. The tools are installed by running ``xcode-select --install``
from the command line. The command line tools are required even if you
have the full Xcode package installed. It may be necessary to run
``sudo xcodebuild -license`` to accept the license prior to using the
tools.
2015-10-12 18:30:01 +03:00
The easiest way to install external libraries is via `Homebrew
2017-02-14 12:27:02 +03:00
<https://brew.sh/>`_. After you install Homebrew, run::
$ brew install libtiff libjpeg webp little-cms2
Install Pillow with::
$ pip install Pillow
2015-10-12 18:30:01 +03:00
or from within the uncompressed source directory::
2015-10-12 18:30:01 +03:00
$ python setup.py install
2015-10-12 18:30:01 +03:00
Building on Windows
^^^^^^^^^^^^^^^^^^^
2014-03-22 03:19:51 +04:00
2015-10-12 18:30:01 +03:00
We don't recommend trying to build on Windows. It is a maze of twisty
passages, mostly dead ends. There are build scripts and notes for the
Windows build in the ``winbuild`` directory.
2014-03-22 03:19:51 +04:00
2015-10-12 18:30:01 +03:00
Building on FreeBSD
^^^^^^^^^^^^^^^^^^^
2014-06-02 02:57:25 +04:00
.. Note:: Only FreeBSD 10 tested
Make sure you have Python's development libraries installed.::
$ sudo pkg install python2
Or for Python 3::
$ sudo pkg install python3
Prerequisites are installed on **FreeBSD 10** with::
$ sudo pkg install jpeg tiff webp lcms2 freetype2
2015-10-12 18:30:01 +03:00
Building on Linux
^^^^^^^^^^^^^^^^^
2015-10-12 18:30:01 +03:00
If you didn't build Python from source, make sure you have Python's
2016-09-03 05:19:04 +03:00
development libraries installed.
In Debian or Ubuntu::
$ sudo apt-get install python-dev python-setuptools
Or for Python 3::
$ sudo apt-get install python3-dev python3-setuptools
In Fedora, the command is::
2016-04-01 13:53:53 +03:00
$ sudo dnf install python-devel redhat-rpm-config
2016-09-03 05:23:42 +03:00
Or for Python 3::
2016-09-03 05:19:04 +03:00
$ sudo dnf install python3-devel redhat-rpm-config
2016-04-01 13:53:53 +03:00
.. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions.
Prerequisites are installed on **Ubuntu 12.04 LTS** or **Raspian Wheezy
7.0** with::
$ sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
Prerequisites are installed on **Ubuntu 14.04 LTS** with::
$ sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
Prerequisites are installed on **Fedora 23** with::
$ sudo dnf install libtiff-devel libjpeg-devel zlib-devel freetype-devel \
lcms2-devel libwebp-devel tcl-devel tk-devel
2014-06-02 02:57:25 +04:00
2014-03-22 03:19:51 +04:00
2015-04-18 01:00:53 +03:00
Platform Support
----------------
Current platform support for Pillow. Binary distributions are contributed for
each release on a volunteer basis, but the source should compile and run
everywhere platform support is listed. In general, we aim to support all
2016-09-23 14:12:03 +03:00
current versions of Linux, macOS, and Windows.
.. note::
2015-10-12 18:30:01 +03:00
Contributors please test Pillow on your platform then update this
document and send a pull request.
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
|**Operating system** |**Supported**|**Tested Python versions** |**Latest tested Pillow version**|**Tested processors** |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| macOS 10.12 Sierra |Yes | 3.4,3.5,3.6 | 4.0.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
2016-10-17 11:12:19 +03:00
| Mac OS X 10.11 El Capitan |Yes | 2.7,3.3,3.4,3.5 | 3.4.1 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Mac OS X 10.10 Yosemite |Yes | 2.7,3.3,3.4 | 3.0.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Mac OS X 10.9 Mavericks |Yes | 2.7,3.2,3.3,3.4 | 3.0.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Mac OS X 10.8 Mountain Lion |Yes | 2.6,2.7,3.2,3.3 | |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Redhat Linux 6 |Yes | 2.6 | |x86 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| CentOS 6.3 |Yes | 2.7,3.3 | |x86 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
2016-02-02 18:06:08 +03:00
| Fedora 23 |Yes | 2.7,3.4 | 3.1.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Ubuntu Linux 14.04 LTS |Yes | 2.7,3.4 | 3.1.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
2016-10-17 11:12:19 +03:00
| Ubuntu Linux 12.04 LTS |Yes | 2.6,2.7,3.2,3.3,3.4,3.5 | 3.4.1 (CI target) |x86,x86-64 |
| | | PyPy5.3.1,PyPy3 v2.4.0 | | |
| | | | | |
2016-10-17 11:12:19 +03:00
| | | 2.7,3.2 | 3.4.1 |ppc |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Ubuntu Linux 10.04 LTS |Yes | 2.6 | 2.3.0 |x86,x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
2016-02-02 18:06:08 +03:00
| Debian 8.2 Jessie |Yes | 2.7,3.4 | 3.1.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
2016-02-02 18:06:08 +03:00
| Raspian Jessie |Yes | 2.7,3.4 | 3.1.0 |arm |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Gentoo Linux |Yes | 2.7,3.2 | 2.1.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Arch Linux |Yes | 2.7,3.6 | 4.0.0 |x86,x86-64 |
2016-10-17 06:20:58 +03:00
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
2016-02-02 18:06:08 +03:00
| FreeBSD 10.2 |Yes | 2.7,3.4 | 3.1.0 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Windows 8.1 Pro |Yes | 2.6,2.7,3.2,3.3,3.4 | 2.4.0 |x86,x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Windows 8 Pro |Yes | 2.6,2.7,3.2,3.3,3.4a3 | 2.2.0 |x86,x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Windows 7 Pro |Yes | 2.7,3.2,3.3 | 3.4.1 |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Windows Server 2012 R2 |Yes | 2.7,3.3,3.4 | 3.4.1 (CI target) |x86,x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
| Windows Server 2008 R2 Enterprise|Yes | 3.3 | |x86-64 |
+----------------------------------+-------------+------------------------------+--------------------------------+-----------------------+
Old Versions
------------
You can download old distributions from `PyPI
<https://pypi.python.org/pypi/Pillow>`_. Only the latest major
releases for Python 2.x and 3.x are visible, but all releases are
available by direct URL access
e.g. https://pypi.python.org/pypi/Pillow/1.0.