cairocffi: pip installation of cairocffi not working on mac

I tried to install cairocffi on Mac. I am getting error while importing cairocffi.

Below are environment details: Model: MacBook Pro OS X: 10.8.5 Python: 2.7.2

Command Log: <snip> sudo pip install cairocffi

…some warnings …

    35 warnings generated.
    clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.8-intel-2.7/c/_cffi_backend.o -L/opt/local/lib -lffi -o build/lib.macosx-10.8-intel-2.7/_cffi_backend.so
    ld: warning: ignoring file /opt/local/lib/libffi.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libffi.dylib

  Running setup.py install for pycparser

Successfully installed cairocffi cffi pycparser
Cleaning up...
SymMacToolkit-C02K824VF1G3:specs nitin_bodke$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairocffi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'libcairo.so.2', 'libcairo-2.dll', 'cairo', 'libcairo-2')
  File "/Library/Python/2.7/site-packages/cairocffi/__init__.py", line 34, in dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "/Library/Python/2.7/site-packages/cffi/api.py", line 117, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/Library/Python/2.7/site-packages/cffi/api.py", line 399, in _make_ffi_library
    backendlib = backend.load_library(name, flags)
OSError: cannot load library libcairo.so.2: dlopen(libcairo.so.2, 2): image not found
>>> 
</snip>

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 24 (9 by maintainers)

Most upvoted comments

@SebaRGFSL

The following export fixed the issue for me:

export DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib

Make sure you have libcairo dependencies within homebrew location (or change it accordingly depending on your setup)

… but

export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib

fixed it for me. Thanks!