How to install Python image library on Mac OS X?

I am a very amateur programmer; I did some kind of recreational algorithmic programming, but I honestly have no idea how libraries and programming languages ​​really fit together. I have to work on a project that requires some image processing, so I tried to install PIL for a while, but I could not.

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

$ python setup.py build_ext -i . 

This was the result 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" caused an error while trying.

Do you guys know what's going on? I am using a MacBook Pro with a Core 2 Duo.

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

+6
python module macos
source share
4 answers

Actually, if you are still using the standard 2.5.x Python that comes with OS X (at least with 10.5.6), there is a pre-created installation package (download dmg for PIL ).

Otherwise, you will need to either build it from the source - this requires tools to create mac files, or install it using MacPorts or fink

edit: Mono makes a good point, you will still need dev tools if you are not using the built-in installer.

+4
source share

You need to install the developer tools that come with your Mac OS X installation DVD.

+3
source share

GCC is the GNU compiler. It is very useful. You just need to install it in any way available for Mac.

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

0
source share

So, this is due to the limitations, but I just ran into a problem.

The problems lie in β†’

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

or wherever your python program is installed.

there is a line that sets compilation flags:

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

I simply removed it from this line and continued my fun journey. Now, obviously, there is a way to configure this from the line above:

 os.environ['ARCHFLAGS'] 

but I don’t know about it and do not want to mess with him.

0
source share

All Articles