Followed the steps How do I install python imaging library (PIL)? for pre-setup libraries to install PIL on Ubuntu 14.04. However when I run pip install PIL --allow-external PIL --allow-unverified PIL seeing the following errors:

building '_imagingft' extension

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/freetype2 -IlibImaging -I/usr/include -I/usr/include/tcl8.6 -I/usr/local/include -I/usr/include/python2.7 -c _imagingft.c -o build/temp.linux-x86_64-2.7/_imagingft.o

_imagingft.c:73:31: fatal error: freetype/fterrors.h: No such file or directory

 #include <freetype/fterrors.h>


compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_ubuntu/PIL/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3ckD6N-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_ubuntu/PIL
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 57: ordinal not in range(128)
  • Was able to install pip install Pillow which is also image library I think so
    – Anuj
    Aug 6 '14 at 5:44

I have successfully installed PIL using these commands:

sudo apt-get build-dep python-imaging
sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
sudo pip install Pillow

After these commands I could:

>>> import PIL
  • 3
    You da real mvp! :D Oct 28 '15 at 21:05
  • 1
    i was able to pip install Pillow after just sudo apt-get install build-dep python-imaging.
    – ryantuck
    Feb 18 '16 at 18:07
  • 1
    @RyanTuck you added an extra install I think but this is much better than just installing a bunch of random packages that I don't know why I'm installing them.
    – YPCrumble
    Jun 16 '16 at 10:07

I had the same error, trying to install Pillow 2.0.0. I found solutions [here].(https://github.com/collective/buildout.python/issues/39)

In short, the location of the freetype library has moved in 14.04. An expedient, if hacky fix, is to make a symlink. On my system, the library was in /usr not /usr/local so I did:

ln -s /usr/include/freetype2 /usr/include/freetype

After doing this, I realized that I might have been able to solve it by updating Pillow to >=2.6.0. But in any case, your issue is installing PIL, so the symlink fix is probably a good one for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.