Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python - igraph plot not available (cairo already installed)

I've installed py2cairo using brew, but keep getting errors when trying to plot with igraph. I get the following error:

>>> import igraph as ig
>>> from igraph import *
>>> UG = ig.Graph()
>>> UG.add_vertex('a')
>>> UG.add_vertex('b')
>>> UG.add_vertex('c')
>>> UG.add_vertex('d')
>>> UG.add_edge('a','d')
>>> UG.add_edge('a','c')
>>> UG.add_edge('b','c')
>>> UG.add_edge('b','a')

>>> layout = UG.layout_kamada_kawai()
>>> plot(UG,layout = layout)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../anaconda/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 427, in plot
    result = Plot(target, bbox, background="white")
  File ".../anaconda/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 122, in __init__
    self._surface_was_created = not isinstance(target, cairo.Surface)
  File ".../anaconda/lib/python2.7/site-packages/igraph/drawing/utils.py", line 396, in __getattr__
    raise TypeError("plotting not available")
TypeError: plotting not available
like image 685
curiousgeorgia Avatar asked Jul 23 '26 03:07

curiousgeorgia


1 Answers

brew probably installs py2cairo for its own Python, while you are running igraph under Anaconda Python. A module installed for one Python distribution on your machine will not appear magically under the other Python distribution, so you'll either have to get py2cairo for Anaconda Python or compile the Python interface of igraph for Homebrew's Python.

like image 64
Tamás Avatar answered Jul 25 '26 16:07

Tamás