简体   繁体   English

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

[英]Installing PIL on OS X Lion (complete noob)

I want to run python's ndimage to do some image analysis. 我想运行python的ndimage来做一些图像分析。 I have a 64-bit Mac running OSX Lion and Python 2.7. 我有一台运行OSX Lion和Python 2.7的64位Mac。 When I tried to run commands from ndimage commands I found out that I need to install PIL. 当我尝试从ndimage命令运行命令时,我发现我需要安装PIL。

I downloaded that and unzipped it (for now into the downloads folder, is there a better place to do it?). 我下载并解压缩它(现在进入下载文件夹,有没有更好的地方去做?)。 I run setup.py and get these messages: 我运行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

I read Failed to build PIL on Mac OS X 10.7 Lion and made sure that I have the 32/64 bit version of python 2.7 installed (Mac OS X 64-bit/32-bit x86-64/i386 Installer (2.7.2) for Mac OS X 10.6 and 10.7 ). 我读到无法在Mac OS X 10.7 Lion上构建PIL并确保我安装了32/64位版本的python 2.7(Mac OS X 64位/ 32位x86-64 / i386安装程序(2.7.2)对于Mac OS X 10.6和10.7)。 I also have Xcode installed. 我也安装了Xcode。 Am I doing something stupid here? 我在这里做些蠢事吗?

Edit 1: looking further, I have found this gcc-4.2 failed with exit status 1 . 编辑1:进一步看,我发现这个gcc-4.2失败,退出状态为1 I've tried entering this when I get the error: 我收到错误后尝试输入此内容:

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

and I get these messages: 我收到这些消息:

_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

Edit 2: I'm not sure if this is the right way to go, but I found a post on installing pil on OSX Leopard and, following its advice, got rid of the -arch i386 part of the command and entered: 编辑2:我不确定这是否是正确的方法,但我发现在OSX Leopard上安装pil帖子,并根据其建议,摆脱命令的-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

Now I only get two errors: 现在我只收到两个错误:

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

From what I can tell at this point the program poops out and doesn't finish compiling. 从我在这一点上可以看出,程序已经消失并且没有完成编译。 Can anyone help me take it from here? 谁能帮助我从这里拿走它?

https://github.com/kennethreitz/osx-gcc-installer/downloads https://github.com/kennethreitz/osx-gcc-installer/downloads

Download GCC for lion. 下载GCC for lion。 It solved all the error: command 'gcc-4.2' failed with exit status 1 problems. 它解决了所有错误:命令'gcc-4.2'因退出状态1问题而失败。

I have had very good success with the MacPorts Python Imaging Library (PIL), Pandas, Numpy and other numerical analysis packages on both Lion and Mountain Lion. 我在Lion和Mountain Lion的MacPorts Python成像库(PIL),Pandas,Numpy和其他数值分析软件包上取得了很大的成功。

Recently there were some significant upgrades with gcc for integration with the latest numerical Python modules on MacPorts. 最近有一些重要的升级与gcc集成在MacPorts上的最新数字Python模块。 Looked like a very significant effort. 看起来非常重要。 I recommend MacPorts unless you are determined to hash through a native install of PIL on Lion. 我建议使用MacPorts,除非您决定在Lion上通过PIL的本机安装进行哈希处理。

I had compiling problems with PIL with Mountain Lion and python 2.7. 我用Mountain Lion和python 2.7编译了PIL的问题。 I used Pillow instead, it's a friendly PIL fork with wider platform support. 我使用了Pillow ,它是一个友好的PIL叉,具有更广泛的平台支持。

regardins your setup questions: 关注你的设置问题:

  • I use macports for python 2.7 and other open source stuff on my mac (libpng, libjpeg, etc for PILLOW) 我在我的mac上使用macports for python 2.7和其他开源东西(libpng,libjpeg等用于PILLOW)
  • virtualenv for creating a virtual python environment (venv will be built-in into python 3.3) virtualenv用于创建虚拟python环境(venv将内置到python 3.3中)
  • I put source code under ~/src (instead Downloads folder) 我把源代码放在〜/ src下(而不是下载文件夹)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM