Error failed building wheel for pillow

Failed building wheel for Pillow. Fixed Python library installation on Ubuntu Linux.

Do you get an error while installing the pillow Python library?

Failed building wheel for Pillow

Pillow is one of the very popular Python libraries and has been used by many other Python libraries as a dependency. So you may come across this failure even if you are trying to install any other library which is dependent on the pillow.

To solve this problem, you have to install two other libraries libjpeg-dev and zlib1g-dev from Linux package manager.

Here is the command. Execute it on bash shell/console.

apt-get install libjpeg-dev zlib1g-dev

And then install the pillow Python module.

That is all. With these simple two commands, you will be able to install the pillow Python module without any hassle.

I come across this error “Failed building wheel for Pillow” while setting up the Python Django project. I have executed these commands on my Ubuntu system and hopefully, it will work with any other Linux OS.

If you still face any issues, let me know in the comment. I will try my best to help you. All the best!

Python Interview Questions eBook

Aniruddha Chaudhari

I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.


Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

(cuckoo) albert@zhuang-pc:~$ pip install cuckoo

Collecting cuckoo

Requirement already satisfied: unicorn==1.0.1 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)

Requirement already satisfied: alembic==0.8.8 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)

Requirement already satisfied: wakeonlan==0.2.2 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)

Collecting sflock<0.3,>=0.2.15 (from cuckoo)

# ...

Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=1.3.4; extra == "security"->requests[security]==2.13.0; sys_platform == "linux2"->cuckoo)

Building wheels for collected packages: pillow

Running setup.py bdist_wheel for pillow ... error

Complete output from command /home/albert/miniconda2/envs/cuckoo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s5clPe/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpN75cBapip-wheel- --python-tag cp27:

running bdist_wheel

running build

running build_py

creating build

# ...

building 'PIL._imagingtk' extension

creating build/temp.linux-x86_64-2.7/Tk

Building using 4 processes

gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c _imagingtk.c -o build/temp.linux-x86_64-2.7/_imagingtk.o

gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c Tk/tkImaging.c -o build/temp.linux-x86_64-2.7/Tk/tkImaging.o

In file included from Tk/tkImaging.c:52:0:

/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory

compilation terminated.

In file included from _imagingtk.c:19:0:

/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory

compilation terminated.

gcc -pthread -shared -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -L/home/albert/miniconda2/envs/cuckoo/lib -Wl,-rpath=/home/albert/miniconda2/envs/cuckoo/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/_imagingtk.o build/temp.linux-x86_64-2.7/Tk/tkImaging.o -L/home/albert/miniconda2/envs/cuckoo/lib -L/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/lib -L/home/albert/miniconda2/envs/cuckoo/lib -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ltk8.6 -lpython2.7 -o build/lib.linux-x86_64-2.7/PIL/_imagingtk.so

gcc: error: build/temp.linux-x86_64-2.7/_imagingtk.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/Tk/tkImaging.o: No such file or directory

error: command 'gcc' failed with exit status 1

----------------------------------------

Failed building wheel for pillow

Running setup.py clean for pillow

Failed to build pillow

Installing collected packages: pillow, peepdf, olefile, python-magic, sflock, scapy, pymongo, idna, pycparser, cffi, enum34, asn1crypto, ipaddress, cryptography, pyOpenSSL, requests, pyelftools, yara-python, python-dateutil, functools32, jsonschema, pymisp, pefile2, cuckoo

Found existing installation: Pillow 4.3.0

Uninstalling Pillow-4.3.0:

Successfully uninstalled Pillow-4.3.0

Running setup.py install for pillow ... error

Complete output from command /home/albert/miniconda2/envs/cuckoo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s5clPe/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-i1e7bP-record/install-record.txt --single-version-externally-managed --compile:

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

# ...

building 'PIL._imagingtk' extension

creating build/temp.linux-x86_64-2.7/Tk

Building using 4 processes

gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c _imagingtk.c -o build/temp.linux-x86_64-2.7/_imagingtk.o

gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c Tk/tkImaging.c -o build/temp.linux-x86_64-2.7/Tk/tkImaging.o

In file included from Tk/tkImaging.c:52:0:

/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory

compilation terminated.

In file included from _imagingtk.c:19:0:

/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory

compilation terminated.

gcc -pthread -shared -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -L/home/albert/miniconda2/envs/cuckoo/lib -Wl,-rpath=/home/albert/miniconda2/envs/cuckoo/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/_imagingtk.o build/temp.linux-x86_64-2.7/Tk/tkImaging.o -L/home/albert/miniconda2/envs/cuckoo/lib -L/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/lib -L/home/albert/miniconda2/envs/cuckoo/lib -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ltk8.6 -lpython2.7 -o build/lib.linux-x86_64-2.7/PIL/_imagingtk.so

gcc: error: build/temp.linux-x86_64-2.7/_imagingtk.o: No such file or directory

gcc: error: build/temp.linux-x86_64-2.7/Tk/tkImaging.o: No such file or directory

error: command 'gcc' failed with exit status 1

----------------------------------------

Rolling back uninstall of Pillow

Command "/home/albert/miniconda2/envs/cuckoo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s5clPe/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-i1e7bP-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-s5clPe/pillow/

Problem:
I am going through a tutorial that required me to install Pillow. I got the following errors when installing it on a vagrant box running Ubuntu Trusty.

Solution:

$ pip install Pillow
...<Lots of output>
ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

  ----------------------------------------
  Failed building wheel for Pillow

Installed libjpeg8-dev to meet the dependency.

$ sudo apt-get install libjpeg8-dev
$ pip install Pillow
...<Lots of output>
ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting

  ----------------------------------------
  Failed building wheel for Pillow

Installed zlib1g-dev to meet the dependency.

$ sudo apt-get install zlib1g-dev
$  pip install Pillow
Collecting Pillow
  Downloading http://192.168.28.189:3141/root/pypi/+f/a64/6493gd7addc02/Pillow-3.2.0.zip (10.5MB)
    100% |████████████████████████████████| 10.5MB 17.6MB/s
Building wheels for collected packages: Pillow
  Running setup.py bdist_wheel for Pillow ... done
  Stored in directory: /home/vagrant/.cache/pip/wheels/f3/66/d4/efw7da4e59d1c94f10f4395887b88ac892263f475
e43242n4q
Successfully built Pillow
Installing collected packages: Pillow
Successfully installed Pillow-3.2.0

Source:
http://stackoverflow.com/questions/36973331/valueerror-jpeg-is-required-unless-explicitly-disabled-using-disable-jpeg-ab

Понравилась статья? Поделить с друзьями:
  • Error failed building wheel for llvmlite
  • Error failed data transfer failure unknown error
  • Error failed building wheel for h5py
  • Error failed building wheel for grpcio
  • Error failed building wheel for gevent