Work-around for Mac OS X python package install error — "lipo: can’t figure out the architecture type"

This is just some quick documentation of a couple of work-arounds I needed to install the a python package on Mac OS X 10.6.6 (Snow Leopard). This solution could work in a number of cases, not just for this one package, so I thought I should write it down.

I was trying to install the nose-cov unit test coverage package, which depends on coverage, using the standard pip/easy_install commands without much luck. The compilation phase spat out a stream of error lines followed by the final message:
failed with error code 1.

Mac OS X 10.4 Support

The first issue was that the coverage package required the optional “Mac OS X 10.4 Support” component of XCode, as hinted at by this message I found in the middle of the error log:

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
Please check your Xcode installation

I did not have the 10.4 components installed on my 10.6 machine despite having the rest of the (presumably 10.5+) components. This is easy to fix by re-running the XCode installation from your OS X disk and choosing the extra option.

GCC Version 4.0 FTW

After installing the 10.4 pieces the installation still failed, this time with the following message near the end of the error log:

lipo: can't figure out the architecture type of: /some/file

error: command 'gcc' failed with exit status 1

[Edit: 2011-02-25]

A much cleaner way to make your system use GCC version 4.0 instead of a later version is to use the CC environment variable. Prefix your pip/easy_install command with CC=/path/to/desired/gcc-version like so:

CC=/usr/bin/gcc-4.0 pip install SOMETHING

Try the CC environment variable approach above before you attempt the hack below.

Google lead me to this post which provided the solution, though it feels like a nasty hack.

My version of OS X (10.6.6) includes two versions of the gcc compiler executable in /usr/bin:

$ ls -al /usr/bin | grep gcc
lrwxr-xr-x     1 root   wheel           7 29 Jan 10:01 cc -> gcc-4.2
lrwxr-xr-x     1 root   wheel           7 29 Jan 10:01 gcc -> gcc-4.2
-rwxr-xr-x     1 root   wheel       97392 18 May  2009 gcc-4.0
-rwxr-xr-x     1 root   wheel      166128 18 May  2009 gcc-4.2
. . .

The gcc symlink points to gcc-4.2 but only the gcc-4.0 version successfully compiles the package. I temporarily moved the original gcc symlink out of the way and created a new one pointing to the 4.0 version, like so:

$ cd /usr/bin
$ sudo mv gcc gcc_orig
$ sudo ln -s gcc-4.0 gcc

I was then able to install the nose-cov package using pip and it ran just fine. Great!

Finally I replaced the original symlink, because forgetting to do so would almost certainly cause something else to break sooner or later:

$ cd /usr/bin
$ sudo rm gcc
$ sudo mv gcc_orig gcc

So in the end my /usr/bin directory looks exactly the same as it used to and the package is installed. Time to go do some real work.

This entry was posted in Python, Tips. Bookmark the permalink.

3 Responses to Work-around for Mac OS X python package install error — "lipo: can’t figure out the architecture type"

  1. Marc says:

    Thanks! Used

    CC=/usr/bin/gcc-4.0 easy_install guppy

    to install guppy-0.1.9 on Mac OS X 10.6.7. Now I’m off to track down a memory leak ….

  2. Didn’t work for me, I still have the same error, installing Fabric.

    Do you have any insight as to why gcc version 4.0 works, but v4.2 does not?

    • James Murty says:

      FWIW I was able to install Fabric 1.4.0 and all dependencies (via pip) with gcc version 4.2.1 on Lion. I no longer have Snow Leopard installed and available for testing.

      I suspect the reason the prior gcc versions work better in some cases is because Makefiles or the build process was written targeting the older OSX libraries, which are used by the older gcc but not the newer one. That’s just a guess though, I never dug deep enough to really understand.

      It may be worth trying other gcc versions if you have them, on the off chance one of them will work.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>