Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PIL on OS X Lion (complete noob)

I want to run python's ndimage to do some image analysis. I have a 64-bit Mac running OSX Lion and Python 2.7. When I tried to run commands from ndimage commands I found out that I need to install 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:

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 ). I also have Xcode installed. Am I doing something stupid here?

Edit 1: looking further, I have found this gcc-4.2 failed with exit status 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:

 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?

like image 895
user1108470 Avatar asked Nov 13 '22 12:11

user1108470


1 Answers

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

Download GCC for lion. It solved all the error: command 'gcc-4.2' failed with exit status 1 problems.

like image 176
ronaldaai Avatar answered Nov 16 '22 04:11

ronaldaai