How do I install pillow in Ubuntu 16.04 LTS?

I went to This site for installing Pillow since the original PIL is a discontinued project and so now not so good to use. But, in the table support for Ubuntu 16.04 LTS is unmentioned. It appears neither in the 4.2.x installation guide, or in the 3.0.0 installation guide.

Further, just installing pillow is said to be not enough. There are some dependencies that should be installed first which is also unmentioned for Ubuntu 16.04 LTS. Would the installation steps for Pillow for python 3 given for 14.04 LTS be OK for Ubuntu 16.04 LTS?

If not, How do I install pillow in 16.04 LTS for Python 3.6? (There is support for Python 2.)


Solution 1:

According to Wikipedia Pillow is packaged as python-pil and python3-pil in Ubuntu 13.04 and later.

To install the Python Imaging Library in Ubuntu 16.04 and later (and also in Ubuntu 14.04), open the terminal and type:

sudo apt install python-pil # for python 2.X

and/or...

sudo apt install python3-pil # for python 3.X including python3.6

And if the imageTk import doesn't work, just do this:

sudo apt install python3-pil.imagetk

Solution 2:

Ubuntu 18.04 and Python 3

This will interest users past Ubuntu 16.04 LTS: install_pillow.sh

#!/bin/bash

apt update
apt install python3-pip -y
apt install libjpeg8-dev zlib1g-dev libtiff-dev libfreetype6 libfreetype6-dev libwebp-dev libopenjp2-7-dev libopenjp2-7-dev -y

pip3 install pillow --global-option="build_ext" --global-option="--enable-zlib" --global-option="--enable-jpeg" --global-option="--enable-tiff" --global-option="--enable-freetype" --global-option="--enable-webp" --global-option="--enable-webpmux" --global-option="--enable-jpeg2000"

This also addresses some of the "dependencies" which I believe OP was referring to:

  • Many of Pillow’s features require external libraries