[cairo] pycairo on OSX: "ImportError: no suitable image found"

Andrea Canciani ranma42 at gmail.com
Sun Nov 21 06:43:35 PST 2010


On Sun, Nov 21, 2010 at 3:31 PM, Ian York <iayork at iayork.com> wrote:
> On Nov 21, 2010, at 3:23 AM, Andrea Canciani wrote:
>> On Sun, Nov 21, 2010 at 2:43 AM, Ian York <iayork at iayork.com> wrote:
>>> I'm trying to install pycairo 1.8.10 on my macbook pro (2.66 GHz Intel Core 2 Duo running MacOS 10.6.5), and pycairo is getting installed but not in a usable way. I get this error message:
>>>
>>> ------------------------------------------------------
>>> ~ > /usr/bin/python
>>> Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
>>> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>> import cairo
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in <module>
>>>  File "/Library/Python/2.6/site-packages/cairo/__init__.py", line 1, in <module>
>>>    from _cairo import *
>>> ImportError: dlopen(/Library/Python/2.6/site-packages/cairo/_cairo.so, 2): no suitable image found.  Did find:
>>>        /Library/Python/2.6/site-packages/cairo/_cairo.so: mach-o, but wrong architecture
>>
>> It looks like you have a 32-bits _cairo.so when python wants a 64 bits
>> one or vice versa.
>> You might want to try building a universal _cairo.so or just check
>> which architecture
>> it is built for right now and build the other one.
>
> Thanks -- how do I do that? I don't see an architecture option in the configuration/build.

I don't know the waf build system, but I would assume that it respects
the CFLAGS and
LDFLAGS set in the environment..

This tech note explains how to set CFLAGS and LDFLAGS for universal builds:
http://developer.apple.com/library/mac/#technotes/tn2005/tn2137.html

Here you can find some additional caveats about universal binaries:
http://cairographics.org/end_to_end_build_for_mac_os_x/
(in the section "Setup environment variables for fat binary compilation").

Andrea


More information about the cairo mailing list