Error installing Python Image Library using pip on Mac OS X 10.9

PythonMacosPip

Python Problem Overview


I want to install PIL on Mavericks using pip but get this error.

_imagingft.c:73:10: fatal error: 'freetype/fterrors.h' file not found
#include <freetype/fterrors.h>
         ^
1 error generated.
error: command 'cc' failed with exit status 1

My Command Line Tools are installed and up to date and every hint I found didn't help. How can I get this to compile?

EDIT: I just checked, freetype is also already installed via homebrew

Python Solutions


Solution 1 - Python

Instead of symlinking to a specific version of freetype2, do this:

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

This saves you the trouble of recreating the symlink whenever you upgrade freetype2.

Solution 2 - Python

With macports, the solution that worked for me:

sudo port install freetype
sudo ln -s /opt/local/include/freetype2 /opt/local/include/freetype

And then re-run the PIL build process.

Solution 3 - Python

I've solved this problem with this symlink:

ln -s /usr/local/Cellar/freetype/2.5.1/include/freetype2 /usr/local/include/freetype

I have freetype already installed via homebrew too.

Solution 4 - Python

This is caused by a change in the headers of freetype >= 2.1.5. PIL is not using the correct documented way to include the freetype headers, which causes the build to fail now that freetype finally removed the long-deprecated way of including the headers. This problem is documented right at the top of http://freetype.sourceforge.net/freetype2/docs/tutorial/step1.html:

> NOTE: Starting with FreeType 2.1.6, the old header file inclusion scheme is no longer supported. This means that you now get an error if you do something like the following: > > #include <freetype/freetype.h>
> #include <freetype/ftglyph.h>

Please take this problem upstream to the developers of PIL and advise them to use the documented way of including freetype headers:

#include <ft2build.h>
#include FT_ERRORS_H

Solution 5 - Python

After many attempts, I solved this problem compiling the PIL without freetype support. To do that, I simply unlinked from my $PATH using brew unlink freetype and then, pip install PIL==1.1.7.

Solution 6 - Python

I just solved this using the steps described in this Stackoverflow answer. Seems this is Xcode's fault for installing freetype in strange locations.

Solution 7 - Python

Use Pillow where this issue is fixed "for real":

And where you can report issues and see them addressed in a timely fashion:

Solution 8 - Python

In my OSx, I found the .h file in /opt/local/include/freetype2 direcoty. So, I type

sudo ln -s /opt/local/include/freetype2/ /usr/local/include/freetype

it works

Maybe the best way is to add /opt/local/include to your clang's include path.

Solution 9 - Python

osx yosemite, this worked for me:

(virtualenv)

$ ln -s /opt/local/include/freetype2/ /usr/local/include/freetype2
$ pip install pil==1.1.7 --allow-external pil --allow-unverified pil

Solution 10 - Python

I'm using Arch Linux and had this issue. In my case had to manually download and unpack the zip file from https://pypi.python.org/pypi/Pillow/2.2.1#downloads . I then edited the file _imagingft.c to change the include path from freetype/fterrors.h to fterrors.h as there was no freetype subdirectory of /usr/include/freetype2 where fterrors.h was located. Finally python setup.py install worked fine.

Edit: I should mention this was the solution for installing Pillow, not PIL, but Pillow is just a fork of PIL and it may still be applicable to others with this issue.

Solution 11 - Python

If you're still looking for answers like I was after reading this and other googling, you may be interested to see this:

Warning

Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.

from here

By the time you read this, the page will probably have changed, but the text will be still here at least.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLukas Spie&#223;View Question on Stackoverflow
Solution 1 - PythonmcuelenaereView Answer on Stackoverflow
Solution 2 - PythonMike FogelView Answer on Stackoverflow
Solution 3 - PythonDmitry AkininView Answer on Stackoverflow
Solution 4 - PythonneverpanicView Answer on Stackoverflow
Solution 5 - PythondiegofleuryView Answer on Stackoverflow
Solution 6 - PythonLukas SpießView Answer on Stackoverflow
Solution 7 - PythonaclarkView Answer on Stackoverflow
Solution 8 - PythonblowyourheartView Answer on Stackoverflow
Solution 9 - PythonIljaView Answer on Stackoverflow
Solution 10 - PythonBeauView Answer on Stackoverflow
Solution 11 - PythonvolvoxView Answer on Stackoverflow