I have an ec2 instance and had Pillow 2.0 installed in my virtualenv initially. Somehow when I tried to upgrade it to Pillow 2.5, it failed with the following message. The e
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.
On my CentOS machine I had to:
yum install python-devel