Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import cairocffi errors on Windows #57

Closed
bzm3r opened this issue May 28, 2015 · 5 comments
Closed

import cairocffi errors on Windows #57

bzm3r opened this issue May 28, 2015 · 5 comments

Comments

@bzm3r
Copy link

bzm3r commented May 28, 2015

Hi,

I have installed cairo on my Windows 8 machine by getting the necessary DLLs from the GTK project, as per the instructions in the cairo documentation.

I put the DLLs supplied from that page into my System32 folder.

Then, I used pip to install cairocffi.

When I try to run a script only with import cairocffi, I get the following error:

    import cairocffi
  File "A:\Anaconda\lib\site-packages\cairocffi\__init__.py", line 41, in <module>
    cairo = dlopen(ffi, *CAIRO_NAMES)
  File "A:\Anaconda\lib\site-packages\cairocffi\__init__.py", line 34, in dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "A:\Anaconda\lib\site-packages\cffi\api.py", line 127, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "A:\Anaconda\lib\site-packages\cffi\api.py", line 572, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "A:\Anaconda\lib\site-packages\cffi\api.py", line 561, in _load_backend_lib
    return backend.load_library(name, flags)
OSError: cannot load library libcairo.so.2: error 0x7e

Why is this happening?

@SimonSapin
Copy link
Member

What is the exact name of the DLL file? Is it one of these? (Namely libcairo-2.dll, probably.) What’s the output of import os; print(os.environ['PATH'])? Is the DLL file in one of those directories? Can you make import cffi; cffi.FFI().dlopen('something.dll') work for some other cairo-related value of something?

@bzm3r
Copy link
Author

bzm3r commented May 28, 2015

What is the exact name of the DLL file? Is it one of these? (Namely libcairo-2.dll, probably.)

That is correct, it is libcairo-2.dll.

What’s the output of import os; print(os.environ['PATH'])? Is the DLL file in one of those directories?

Yes. System32 is one of the directories output by os.environ['PATH']. I also noticed that I have the DLLs under A:\Anaconda\Lib\site-packages\gtk-2.0\runtime\bin (which was created by my pygtk installation, I believe).

Can you make import cffi; cffi.FFI().dlopen('something.dll') work for some other cairo-related value of something?

What would be some other sensical value for something.dll? I tried libcairo-gobject-2.dll and got the following error:

return backend.load_library(path, flags)
OSError: cannot load library A:\Anaconda\lib\site-packages\gtk-2.0\runtime\bin\libcairo-gobject-2.dll: error 0xc1
```python

@SimonSapin
Copy link
Member

Random idea: is your Python 32-bit or 64-bit? Does this match your cairo DLLs?

Other than this I don’t know what else to suggest, sorry. I don’t use Windows myself.

@SimonSapin
Copy link
Member

More precisely, if you have a libcairo-2.dll file in a directory that’s in $PATH for the same architecture (32 vs 64-bit) as your Python and import cffi; cffi.FFI().dlopen('libcairo-2.dll') doesn’t work, there is some other issue on your system that I don’t understand and that is probably not a bug in cairocffi.

@bzm3r
Copy link
Author

bzm3r commented May 28, 2015

My Python is 64-bit. Based on your suggestion, I cleared up all installed DLLs, and then got the 64-bit versions (again, from the GTK project), and put them into a special folder ("cairo_dlls") which I then added to the path. I still get the same error.

  File "A:\Anaconda\lib\site-packages\cffi\api.py", line 567, in _load_backend_lib
    return backend.load_library(path, flags)

OSError: cannot load library A:\cairo_dlls\libcairo-2.dll: error 0x7e

Other than this I don’t know what else to suggest, sorry. I don’t use Windows myself...here is some other issue on your system that I don’t understand and that is probably not a bug in cairocffi.

Okay, makes sense. I will just switch to my Ubuntu installation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants