python – 在OS X Lion上安装PIL(完整的菜鸟)

我想运行pythonndimage进行一些图像分析.我有一台运行OSX Lion和Python 2.7的64位Mac.当我尝试从ndimage命令运行命令时,我发现我需要安装PIL.

我下载并解压缩它(现在进入下载文件夹,有没有更好的地方去做?).我运行setup.py并获取以下消息:

running install
running build
running build_py
running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.6-intel-2.7/_imaging.o
unable to execute gcc-4.2: No such file or directory
error: command 'gcc-4.2' failed with exit status 1

我阅读了Failed to build PIL on Mac OS X 10.7 Lion并确保安装了32/64位版本的python 2.7(适用于Mac OS X 10.6和10.7的Mac OS X 64位/ 32位x86-64 / i386安装程序(2.7.2)).我也安装了Xcode.我在这里做些蠢事吗?

编辑1:
进一步看,我已经找到了这个gcc-4.2 failed with exit status 1.当我收到错误时我试过输入这个:

llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.6-intel-2.7/_imaging.o

我收到这些消息:

_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type

编辑2:
我不确定这是否是正确的方法,但我找到了post on installing pil on OSX Leopard,并按照其建议,摆脱了-arch i386部分命令并进入:

 llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.6-intel-2.7/_imaging.o

现在我只收到两个错误:

_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type

从我在这一点上可以看出,程序已经消失并且没有完成编译.谁能帮助我从这里拿走它?

最佳答案
https://github.com/kennethreitz/osx-gcc-installer/downloads

下载GCC for lion.它解决了所有错误:命令’gcc-4.2’失败,退出状态为1
问题.

转载注明原文:python – 在OS X Lion上安装PIL(完整的菜鸟) - 代码日志