Python igraph unable to plot

纵然是瞬间 提交于 2020-01-15 03:46:27

问题


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:


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.



来源:https://stackoverflow.com/questions/34251426/python-igraph-unable-to-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!