1

当我尝试在 Mac OS X 10.8.1 Mountain Lion 上构建 PIL 时,我得到以下结果:

$ 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
4

2 回答 2

5

PIL 跟不上对新操作系统的支持(通过更改 setup.py 以获取新的 lib 目录等)。但是,您可以使用“友好的 PIL fork”枕头代替 PIL :

如果您遇到同样的错误,请报告问题:

于 2012-08-29T15:03:55.340 回答
0

这个 SO question中,我能够在 /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 中找到 Python.h。(注意我已经安装了 Xcode)

然后我跑了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

(注意:/Developer/SDKs/MacOSX10.7.sdk/usr/include添加是因为 Python.h 解决后 stdio.h 丢失)

最后,我跑了sudo python setup.py install

于 2012-08-29T14:25:24.460 回答