我想运行python的ndimage来进行一些图像分析。我有一台运行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的Mac OS X 64位/ 32位x86-64 / i386安装程序(2.7.2) OS X 10.6和10.7)。我也安装了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
从我现在所知的程序开始,程序没有完成编译。谁能帮助我从这里拿走它?
答案 0 :(得分:1)
https://github.com/kennethreitz/osx-gcc-installer/downloads
为狮子下载GCC。它解决了所有错误:命令'gcc-4.2'失败,退出状态为1 问题。
答案 1 :(得分:0)
我在Lion和Mountain Lion上使用MacPorts Python成像库(PIL),Pandas,Numpy和其他数值分析软件包取得了非常好的成功。
最近,使用gcc进行了一些重大升级,以便与MacPorts上最新的数字Python模块集成。看起来非常重要。我推荐使用MacPorts,除非您决定在Lion上通过本地安装的PIL进行哈希。
答案 2 :(得分:0)
我用Mountain Lion和python 2.7编译了PIL的问题。我使用Pillow代替它,它是一个友好的PIL分支,具有更广泛的平台支持。
关注您的设置问题: