Error for pip install Pillow on Ubuntu virtualenv

My case was slightly different as my ubuntu 15.04 was missing also libjpeg, so the installation failed each time. Apparently sometimes pillow can not find required library and the easiest way to fix it is to install the dev version and link it to the user libs. Edit: also works in ubuntu 16.04

sudo apt-get install python-dev
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib

pip install pillow

Partial solution found here


Note for myself and any others, getting this to compile on Elementary OS Luna (Ubuntu 12.04) requires installation of the python headers you need for your virtualenv python version per the comments on the OP. I am using the default python version and testing 3.4 (via deadsnakes ppa) so for me this was:

sudo apt-get install python-dev
sudo apt-get install python3.4-dev

BUT! I was still getting the same error! I checked my .bashrc per the OPs answer, I didn't have any matching exports. Then it hit me, I'd been troubleshooting for a while and from an answer somewhere else I had tried setting those and hadn't restarted bash.

So don't forget to restart (or re-source I suppose) bash to make sure your exports match .bashrc!

edit: This is a bit long for a comment but not really an answer. Will modify if necessary.


I had the same headache too...

The solution was found after reading docs, that says:

Starting from version 3.0.0 Pillow needs libjpeg...

So try the previous one:

pip install pillow==2.9.0

(It works for python 2.6 and above)

Good Luck!