简体   繁体   中英

How do I install Python Imaging Library on Mac OS X?

I'm an extremely amateur programmer; I've done some recreational algorithmics programming, but I honestly have no idea how libraries and programming languages really fit together. I'm supposed to work on a project that requires some image processing, so I've been trying to install PIL for a while, but I haven't been able to.

I went to http://www.pythonware.com/products/pil/ and downloaded "Python Imaging Library 1.1.6 Source Kit (all platforms) (440k TAR GZ) (December 3, 2006)". Then I opened the folder in my command prompt and ran

$ python setup.py build_ext -i .

This was the output I got:

running build_ext

--- using frameworks at /System/Library/Frameworks

building '_imaging' extension

gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe -DHAVE_LIBZ -IlibImaging -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _imaging.c -o build/temp.macosx-10.5-i386-2.5/_imaging.o

unable to execute gcc: No such file or directory

error: command 'gcc' failed with exit status 1

"import Image" produced an error when I tried it.

Do you guys have any idea what's going on? I'm using a MacBook Pro with a Core 2 Duo.

And I'm honestly sorry if this is ridiculously stupid.

Actually, assuming you're still using the default 2.5.x Python that comes with OS X (at least as of 10.5.6), there's a pre-built installer package for it (download the dmg for PIL ).

Otherwise, you'll need to either build it from source -- which does require the mac dev tools -- or install it with MacPorts or fink

edit: mono makes a good point, you'll still need the dev tools unless you use the pre-built installer.

您需要安装Mac OS X安装DVD上的开发人员工具。

So this is from awhile ago, but I just ran into the problem.

The issues lies with ->

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py

or wherever your python install is.

there is a line that sets the compile flags:

archflags = '-arch i386 -arch ppc -arch x86_64'

I just removed it from that line and went on my merry way. Now there is obviously a way to configure this from the line above:

os.environ['ARCHFLAGS']

but I don't know about that, and didn't want to mess with it.

GCC is the GNU compiler. It's a very useful thing to have. You just need to install it in whatever mac-friendly way exists.

http://www.tech-recipes.com/rx/726/mac-os-x-install-gcc-compiler/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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