Fail during installation of Pillow (Python module) in Linux
Asked Answered
U

13

180

I'm trying to install Pillow (Python module) using pip, but it throws this error:

ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

So as the error says, I tried:

pip install pillow --global-option="--disable-jpeg"

But it fails with:

error: option --disable-jpeg not recognized

Any hints how to deal with it?

Unlade answered 6/1, 2016 at 11:16 Comment(0)
U
36

Thank you @mfitzp. In my case (CentOS) these libs are not available in the yum repo, but actually the solution was even easier. What I did:

sudo yum install python-devel
sudo yum install zlib-devel
sudo yum install libjpeg-turbo-devel

And now pillow's installation finishes successfully.

Unlade answered 6/1, 2016 at 11:39 Comment(4)
Thanks that worked for me although I didn't need the python-develPricefixing
Worked for me too, just needed to install the libjpeg-turbo-devel package!They
Worked on CentOS 7 like a charm!Peder
This python-devel was not required on amazon linux yum machine. I think the last one libjpeg-turbo-devel was the missing package.Civil
F
351

There is a bug reported for Pillow here, which indicates that libjpeg and zlib are now required as of Pillow 3.0.0.

The installation instructions for Pillow on Linux give advice of how to install these packages. Note that not all of the following packages may be missing on your machine (comments suggest that only libjpeg8-dev is actually missing).

pip / PyPi (Pillow>3.4.2)

The latest releases of Pillow are available on PyPi as wheels — the new standard packaging mechanism for Python. These prebuilt packages include all neccessary binary dependencies to allow Pillow to run and should be used if you want to install Pillow using PyPi

To use wheels, you need to have a version of pip>=1.4. If you are using an earlier version (pip --version) upgrade pip using the following:

pip install --upgrade pip 

Once pip is upgraded, pip install will use platform-specific wheel files by default if they are available. Use the following command to upgrade Pillow to the latest version available on PyPi:

pip install --upgrade pillow

Ubuntu 12.04 LTS or Raspian Wheezy 7.0

sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

Ubuntu 14.04

sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk

Ubuntu 18.04

sudo apt install libjpeg8-dev zlib1g-dev

Fedora 20

The Fedora 20 equivalent of libjpeg8-dev is libjpeg-devel.

sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel

Mac OS X (via Homebrew)

On Mac OS X with Homebrew this can be fixed using:

brew install libjpeg zlib

You may also need to force-link zlib using the following:

brew link zlib --force

Update April 2019: In Mojave the above will not work and you need to run the following as taken from this bug report on Pillow

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Update July 2016: There is no longer a formula for zlib available in the main repository (Homebrew will prompt you to install lzlib which is a different library and will not solve this problem).

There is a formula available in the dupes repository. You can either tap this repository, and install as normal:

brew tap homebrew/dupes
brew install zlib

Or you can install zlib via xcode instead, as follows:

xcode-select --install

Thanks to phoenix, Panos Angelopoulou, nelsonvarela, benjaminz and Kal in the comments

After these are installed the pip installation of Pillow should work normally.

Feeling answered 6/1, 2016 at 11:25 Comment(10)
Just libjpeg8-dev might be fine.Beget
I was facing the same problem for Mac OS X. I solve it executing brew install libjpeg brew install zlibChalcidice
Better install libjpeg-dev - with no '8', then also found that zlib1g-dev was missing too. After: sudo apt-get install libjpeg-dev zlib1g-dev the pip Pillow install worked on Mint 17.1 (= Ubuntu 14.04 LTS).Helvellyn
I had to force link zlib: brew link zlib --forceGirandole
@Girandole thank you so much for saying that. I've been trying to fix this for a week and tried everything. brew link zlib --force is what did it!Bowfin
El Capitan, Python 3.5.1: brew install libjpeg fixed itPlumper
what about ubuntu 1604Pangermanism
apk add jpeg-dev for alpineWhitebait
sudo apt install libjpeg8-dev worked for me, ubuntu 18.04Filly
Starting with recent Homebrews, brew link zlib will not work. macOS Mojave also doesn't seem to install Zlib header with xcode, so see this issue for a work-around.Langlois
U
36

Thank you @mfitzp. In my case (CentOS) these libs are not available in the yum repo, but actually the solution was even easier. What I did:

sudo yum install python-devel
sudo yum install zlib-devel
sudo yum install libjpeg-turbo-devel

And now pillow's installation finishes successfully.

Unlade answered 6/1, 2016 at 11:39 Comment(4)
Thanks that worked for me although I didn't need the python-develPricefixing
Worked for me too, just needed to install the libjpeg-turbo-devel package!They
Worked on CentOS 7 like a charm!Peder
This python-devel was not required on amazon linux yum machine. I think the last one libjpeg-turbo-devel was the missing package.Civil
D
36

On Raspberry pi II, I had the same problem. After trying the following, I solved the problem. The solution is:

sudo apt-get update
sudo apt-get install libjpeg-dev
Dato answered 22/2, 2016 at 6:29 Comment(1)
sudo apt-get install libjpeg-dev worked for Ubuntu 14 also ):Derk
P
14

The quickest fix is upgrate the pip. Did worked for me:

pip install --upgrade pip
Pensive answered 11/9, 2016 at 7:23 Comment(2)
worked for me. Pip install Pillow (if not working clear cache by pip install --upgrade pip) Then run again Pip install PillowOstracoderm
This also worked for me. I have Python 2.6.6 and 3.5.1 on a CentOS VM, and ran pip3.5 install --upgrade pip3.5. After that, pip3.5 install pillow ran without any issues, and maintained the integrity of the Python2 and Python3 installations.Patrology
M
13

This worked for me to solve jpeg and zlib error :

C:\Windows\system32>pip3 install pillow --global-option="build_e
xt" --global-option="--disable-zlib" --global-option="--disable-jpeg"
Micronutrient answered 23/1, 2018 at 11:12 Comment(1)
I needed to install Pillow on an environment where I don't have root access - this is the solution that worked for me.Shrievalty
A
12

This worked for me.

   `sudo apt-get install libjpeg-dev`
Amiraamis answered 14/7, 2017 at 18:16 Comment(0)
J
10
brew install zlib

on OS X doesn't work anymore and instead prompts to install lzlib. Installing that doesn't help.

Instead you install XCode Command line tools and that should install zlib

xcode-select --install
Jelks answered 14/4, 2016 at 15:21 Comment(1)
A little more explanation would be much more helpful.Trollope
E
6

I had the ValueError: zlib is required unless explicitly disabled using --disable-zlib but upgrading pip from 7.x to 8.y resolved the problem.

So I would try to update tools before anything else.

That can be done using:

pip install --upgrade pip
Equinox answered 6/8, 2016 at 12:29 Comment(0)
S
2

The alternative, if you don't want to install libjpeg:

CFLAGS="--disable-jpeg" pip install pillow

From https://pillow.readthedocs.io/en/3.0.0/installation.html#external-libraries

Shower answered 28/8, 2016 at 4:19 Comment(0)
P
2

Working successfuly :

 sudo apt install libjpeg8-dev zlib1g-dev 
Pros answered 4/8, 2020 at 8:39 Comment(1)
Worked for me on Ubuntu 20.04, Python 3.8.5Deluna
H
2

Anyone with Python 3.9 you can only install Pillow 8.0, Any version lower than that wouldn't work. For more check here.

So you can run it like this:

pip install Pillow==8.0.0

BTW this is tested on pip 21.0.1 (python 3.9) on MacOS Big Sur 11.2

Hades answered 3/3, 2021 at 9:30 Comment(1)
Savior ! shukraaan .Spermophile
O
0

Try

pip install pillow

If it doesn't work, try clearing the

cache by pip install --upgrade pip

Then again run

pip install pillow
Ostracoderm answered 11/9, 2016 at 15:57 Comment(0)
D
-3

On debian / ubuntu you only need: libjpeg62-turbo-dev

So a simple sudo apt install libjpeg62-turbo-dev and a pip install pillow

Defense answered 16/9, 2016 at 16:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.