1

When I try to build PIL on Mac OS X 10.8.1 Mountain Lion, I get the following result:

$ sudo python setup.py install
Password:
running install
running build
running build_py
running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -IlibImaging -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
_imaging.c:75:10: fatal error: 'Python.h' file not found
#include "Python.h"
         ^
1 error generated.
error: command 'clang' failed with exit status 1
Dolan Antenucci
  • 15,432
  • 17
  • 74
  • 100
  • Is this an upgrade or a clean install? I can't reproduce on a clean install. – aclark Sep 08 '12 at 02:03
  • This was an upgrade from Lion (10.7.4 I think), which also had Python manually upgraded to 2.7. Since Pillow works on a clean install, I think that's an acceptable enough answer for me. Thanks for checking on this, and for your work on Pillow :) – Dolan Antenucci Sep 09 '12 at 03:33

2 Answers2

5

PIL does not keep up with support for new operating systems (by making changes to setup.py for new lib dirs, etc). But intstead of PIL, you can use the "friendly PIL fork" Pillow:

And if you get the same error, please report the issue:

aclark
  • 4,345
  • 1
  • 19
  • 31
0

From this SO question, I was able to find Python.h in /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7. (note that i have Xcode installed)

I then ran sudo python setup.py build_ext --include-dirs /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7:/Developer/SDKs/MacOSX10.7.sdk/usr/include

(note: /Developer/SDKs/MacOSX10.7.sdk/usr/include added because stdio.h was missing once the Python.h was resolved)

Finally, I ran sudo python setup.py install

Community
  • 1
  • 1
Dolan Antenucci
  • 15,432
  • 17
  • 74
  • 100