Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Cairo and PyCairo Mac OsX

I am playing around with using python iGraph for network visualization. I got his error message when I tried to plot a graph:

>>> layout = g.layout("kk")
>>> plot(g, layout = layout)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/__init__.py", line 446, in plot
  File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/__init__.py", line 117, in __init__
  File "build/bdist.macosx-10.5-x86_64/egg/igraph/drawing/utils.py", line 396, in __getattr__
TypeError: plotting not available

I don't think I installed Cairo or PyCairo correctly.

I am not familiar using Fink or MacPorts, since I commonly use Homebrew.

Any help you be greatly appreciated.

like image 538
Rodrigo Matus-Nicodemos Avatar asked May 30 '26 19:05

Rodrigo Matus-Nicodemos


2 Answers

You need to manually compile the library. I used the solution here and just updated the version.

curl -L https://www.cairographics.org/releases/cairo-1.14.6.tar.xz -o cairo.tar.xz
tar -xf cairo.tar.xz && cd cairo-1.14.6
./configure --prefix=/usr/local --disable-dependency-tracking
make install

If while running configure, you get an error about pkg_config, you can install that with brew:

brew install pkg-config
like image 137
Nikign Avatar answered Jun 02 '26 19:06

Nikign


I had the same problem on my MacBook so I wanted to share my solution.

I tried to install pycairo, py2cairo. The installation seemed to be okay but then:

  1. I could not import pycairo
  2. igraph's plot would not work.

The following solved the igraph plotting issue:

sudo pip install cairocffi

or just

pip install cairocffi

So instead of pycairo I used cairocffi and this did the trick.

like image 32
seralouk Avatar answered Jun 02 '26 19:06

seralouk