Python: OSError: cannot load library libcairo.so.2

Niddro picture Niddro · Jan 29, 2015 · Viewed 27.2k times · Source

I'm having some trouble running a python script on my Windows 7 platform. I've installed Python and also cairo, last one using "pip". I'm running the script using this command:

C:\Python34>python.exe label/make_label.py

and I get the following error message:

Traceback (most recent call last):
  File "label/make_label.py", line 6, in <module>
    import cairocffi as cairo
  File "C:\Python34\lib\site-packages\cairocffi\__init__.py", line 41, in <modul
e>
    cairo = dlopen(ffi, *CAIRO_NAMES)
  File "C:\Python34\lib\site-packages\cairocffi\__init__.py", line 34, in dlopen

    return ffi.dlopen(names[0])  # pragma: no cover
  File "C:\Python34\lib\site-packages\cffi\api.py", line 118, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Python34\lib\site-packages\cffi\api.py", line 411, in _make_ffi_libra
ry
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Python34\lib\site-packages\cffi\api.py", line 400, in _load_backend_l
ib
    return backend.load_library(name, flags)
OSError: cannot load library libcairo.so.2: error 0x7e

What I've already done is the following:

  • Added the PATH to GTK/bin in the environmental variable
  • I check the folder GTK/bin and found "libcairo-2.dll" so I renamed it to libcairo.so

I don't know what other information could be useful in solving this but please let me know and I'll try to add it.

Answer

Hexatonic picture Hexatonic · Mar 9, 2016

On Mac OS X using homebrew:

brew install cairo
brew install pango