77

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

2
  • You need freetype headers.
    – devnull
    Commented Dec 2, 2013 at 10:03
  • Yes, I guessed that ;) Also just found a way to solve this. Commented Dec 2, 2013 at 10:11

11 Answers 11

209

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.

6
  • 1
    after using sudo easy_install PIL, I come across this issue, your solution works like a charm! Thanks!
    – spiralmoon
    Commented Jun 16, 2014 at 6:03
  • 3
    this fixed the issue on Yosemite too Commented Feb 4, 2015 at 21:09
  • I had freetype2 already linked, it may be best to link the original which was at /usr/local/Cellar/freetype/2.5.5/include/freetype2
    – Salyangoz
    Commented May 6, 2015 at 23:23
  • 1
    @Salyangoz: /usr/local/include/freetype2 is a symlink to /usr/local/Cellar/freetype/2.5.5/include/freetype2 (it's created by Homebrew). Using this instead of the actual path, has the advantage when doing an upgrade that it will still work. Commented May 16, 2015 at 16:01
  • 2
    Freetype2 was not installed on my machine running El Capitan, so I had to run brew install freetype before making this symlink Commented Dec 8, 2015 at 1:17
31

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.

2
  • this worked for me when i upgraded to maverick thanks Commented Jan 24, 2014 at 19:50
  • worked for me on yosemite while upgrading to cocos2dx v3.3 from 2.2
    – andrewz
    Commented Feb 22, 2015 at 20:47
27

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.

5

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

4

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.

1
  • what is freetype, anyway? :)
    – stantonk
    Commented May 26, 2015 at 21:23
3

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

3

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

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

2

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.

1

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
1
  • Ran the first line only, then this worked for me on Yosemite. Was able to pip install PIL
    – Aaron Ash
    Commented Aug 15, 2015 at 8:11
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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