Problem installing Cairo library

Hello guys, I’m having a lot of troubles trying to use igraph.
Whatever I do or write, when I run the code, it generates always this message:

C:\Users\Marco\PycharmProjects\ortuproject\venv\Scripts\python.exe “C:/Users/Marco/PycharmProjects/ortuproject/Teoria Dei Grafi_script con NetworkX.py”
Traceback (most recent call last):
File “C:/Users/Marco/PycharmProjects/ortuproject/Teoria Dei Grafi_script con NetworkX.py”, line 1, in
from igraph import *
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\igraph_init_.py”, line 35, in
from igraph.clustering import *
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\igraph\clustering.py”, line 36, in
from igraph.drawing.colors import ClusterColoringPalette
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\igraph\drawing_init_.py”, line 30, in
from igraph.drawing.graph import DefaultGraphDrawer
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\igraph\drawing\graph.py”, line 27, in
from igraph.drawing.edge import ArrowEdgeDrawer
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\igraph\drawing\edge.py”, line 17, in
cairo = find_cairo()
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\igraph\drawing\utils.py”, line 413, in find_cairo
module = import(module_name)
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\cairocffi_init_.py”, line 50, in
(‘libcairo.so’, ‘libcairo.2.dylib’, ‘libcairo-2.dll’))
File “C:\Users\Marco\PycharmProjects\ortuproject\venv\lib\site-packages\cairocffi_init_.py”, line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called “cairo” was found
no library called “libcairo-2” was found
cannot load library ‘libcairo.so’: error 0x7e
cannot load library ‘libcairo.2.dylib’: error 0x7e
cannot load library ‘libcairo-2.dll’: error 0x7e

a guy told me to install Cairo from the site cairographics / download

but I’m a noob and I don’t understand he instructions. I tried to follow this one:

From Dominic Lachowicz:

Since GTK+ 2.8 and newer depends on Cairo, you can have Cairo installed on Win32 as a side-effect of installing GTK+. For example, see [The Glade/GTK+ for Windows Toolkit](gladewin32 sourceforge).

but what shoul Ido with GTK? trying pip install gtk? or install some stuff from this page?

also gtk site at the download page gives the 404 error.

I apologise if I committed some formal error writing, this is my first question but I need to learn igraph for a thesis project and I’m afraid that alone i would be stuck.

thanks!

On Windows it would be most convenient to simply install the python-igraph library through Anaconda. That way, all necessary libraries are installed for you, including the pycairo python library and the necessary cairo library.

1 Like

Some further info: it looks like you have cairocffi on your machine. cairocffi is a Python binding to the Cairo library, but it needs Cairo itself to work correctly. There are three paths ahead that you can take. The easiest is probably the one suggested by @vtraag: just install python-igraph from Anaconda Python and you’ll get all the dependencies, pre-compiled and nicely wrapped up. If you insist on using the “normal” Python on Windows, you either need to install the Cairo library itself so cairocffi can find it without blowing up, or you need to uninstall cairocffi and accept the limitation that you won’t be able to plot graphs from igraph. (But otherwise it would work just fine, the plotting related parts of the library would be disabled).