Python igraph unable to plot

2019-07-10 04:26发布

I wanted to perform a simple plot with igraph but i get the following error:

File "testigraph.py", line 51, in <module>
plot(g, **visual_style)
File "/Library/Python/2.7/site-packages/igraph/drawing/__init__.py", line 446, in plot
result = Plot(target, bbox, background=kwds.get("background", "white"))
File "/Library/Python/2.7/site-packages/igraph/drawing/__init__.py", line 117, in __init__
self._surface_was_created = not isinstance(target, cairo.Surface)
File "/Library/Python/2.7/site-packages/igraph/drawing/utils.py", line 396, in __getattr__
raise TypeError("plotting not available")

It looks like this error python + igraph "plotting not available" but I still cannot fix my problem. I tried following Cairo install instructions on http://igraph.org/python/doc/tutorial/install.html#installing-igraph but i dont see how to get it working.

--- EDIT

Now I get this error:

OSError: dlopen() failed to load a library: cairo / cairo-2

I found this solution Trouble running WeasyPrint after installing El Capitan (OSX 10.11) but it does not apply to OS X Yosemite. Running

csrutil status

Returns command not found.

Thanks!

1条回答
孤傲高冷的网名
2楼-- · 2019-07-10 04:52

Same problem here ! 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

So instead of pycairo I used cairocffi.

查看更多
登录 后发表回答