5

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?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Did you create a symlink like the user who posted about gcc? – Wayne Werner Dec 20 '11 at 19:44
  • thanks for the reply. I tried going to the developer folder and entering 'ln -s llvm-gcc-4.2 gcc-4.2' if that is what you mean – user1108470 Dec 20 '11 at 19:50
  • use the back-quote for escaping (though I don't think it gives you newlines in comments). I have no access to a mac, so I'm just making educated guesses. So now the compile dies yet again? – Wayne Werner Dec 20 '11 at 19:56
  • updated the main question so it's more readable, but basically I think it does die again here – user1108470 Dec 20 '11 at 20:00
  • Did you look at http://www.p16blog.com/p16/2008/05/appengine-installing-pil-on-os-x-1053.html – luc Dec 20 '11 at 20:33
  • That looks like it could be really helpful. I did the first half and created the symbolic link. When he started talking about bashrc he lost me though. Is this part necessary? How do I edit /.bashrc? thanks for the help! – user1108470 Dec 20 '11 at 20:58
  • also, i tried creating the link to python.framework and it said the file python.framework exists. Is this because I did it before? what should my frameworks folder look like? Thanks, sorry to be so helpless – user1108470 Dec 20 '11 at 21:29

3 Answers3

1

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.

ronaldaai
  • 11
  • 1
0

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.

Recently there were some significant upgrades with gcc for integration with the latest numerical Python modules on MacPorts. Looked like a very significant effort. I recommend MacPorts unless you are determined to hash through a native install of PIL on Lion.

zerocog
  • 1,703
  • 21
  • 32
0

I had compiling problems with PIL with Mountain Lion and python 2.7. I used Pillow instead, it's a friendly PIL fork with wider platform support.

regardins your setup questions:

  • I use macports for python 2.7 and other open source stuff on my mac (libpng, libjpeg, etc for PILLOW)
  • virtualenv for creating a virtual python environment (venv will be built-in into python 3.3)
  • I put source code under ~/src (instead Downloads folder)
yvess
  • 1,992
  • 19
  • 17