18

Xcode4 dropped PPC support, so when I try building PIL, it throws hate:

Bens-MacBook-Air:Imaging-1.1.7 bkeating$ python setup.py build
running buildrunning build_pyrunning build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
/usr/bin/gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -I/usr/local/include/freetype2 -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.6/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c decode.c -o build/temp.macosx-10.6-universal-2.6/decode.o
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
decode.c:688: fatal error: error writing to -: Broken pipe
compilation terminated.
lipo: can't open input file: /var/folders/jW/jW0VkC8uEb4lAjcJou+OaU+++TI/-Tmp-//ccEmCpUp.out (No such file or directory)
error: command '/usr/bin/gcc-4.0' failed with exit status 1

I ran that first line, manually, and removed the -arch ppc option and it didn't report back with any errors, but rerunning the build process ignores this manual attempt. `gcc-4.0 also does not exist, I symlinked it to gcc-4.2.

I could go ahead and install Xcode3 and then 4, but I want to muck up my fresh install.

Is there anyway to tell PIL to not compile for PPC? I did a grep across the distribution but i did not find a single mention of PPC. Any ideas?

Jon-Eric
  • 16,977
  • 9
  • 65
  • 97
Ben Keating
  • 8,206
  • 9
  • 37
  • 37
  • 5
    SOLVED: The solution has nothing to do with PIL but rather setting gcc's ARCHFLAGS. eg. ``ARCHFLAGS="-arch i386 -arch x86_64" sudo pip install PIL``. – Ben Keating Mar 20 '11 at 06:23
  • 5
    You should have stated that as an answer. You're allowed/encouraged to answer your own questions (provided you really are giving answers of course). – Donal Fellows Mar 20 '11 at 07:23
  • while i get no error using this command line and it says success I get "ImportError: No module named PIL" with all scripts – Bastian Mar 23 '11 at 23:23

4 Answers4

38

The solution has nothing to do with PIL but rather setting gcc's ARCHFLAGS:

ARCHFLAGS="-arch i386 -arch x86_64" sudo pip install PIL
Jon-Eric
  • 16,977
  • 9
  • 65
  • 97
Ben Keating
  • 8,206
  • 9
  • 37
  • 37
  • 11
    Instead of writing "SOLVED", just click the checkmark next to the answer which solved the problem for you. – Tyler Mar 20 '11 at 17:40
16

ARCHFLAGS doesn't seem to get passed into sudo. I had to do

sudo -s

then ARCHFLAGS="-arch i386 -arch x86_64" pip install PIL to make it work.

alphageek
  • 770
  • 4
  • 15
14

A better way to solve this issue, in my opinion, would be to edit your ~/.profile or /etc/bashrc and add the line:

export ARCHFLAGS="-arch i386 -arch x86_64"

Will save messing around with any future installations (I've just had to do this for installing lots of Perl modules in CPAN)!

gawbul
  • 1,207
  • 12
  • 20
  • 1
    +1, worked for me. @Steve, I don't currently use Xcode, but is there a downside to setting this environment variable (and forgetting I did) and later using Xcode for, say, iOS development? Or does Xcode explicitly override this variable? – brainjam Jun 28 '11 at 16:21
  • Not as far as I am aware? I think this is an issue in upgrading from an older OS X release (that supports PPC) to a newer one (e.g. Snow Leopard or Lion) and perhaps with the new XCode too? I had a fresh install of Snow Leopard and have since upgraded to Lion and haven't had this issue! – gawbul Jul 07 '11 at 08:41
1

Just to help others... I had to use ARCHFLAGS="-arch x86_64" before building imaging with my Snow Leopard/XCode 4 system i.e. having "-arch i386" in their stopped it working for me.

sthartle
  • 91
  • 1
  • 5