本文介绍了Python igraph无法绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用igraph执行一个简单的绘图,但是出现以下错误:

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")

看起来像这样的错误 python + igraph无法绘制" ,但是我仍然无法解决我的问题.我尝试按照 http://igraph.org/python上的开罗安装说明进行操作/doc/tutorial/install.html#installing-igraph ,但我不知道如何使它正常工作.

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.

---编辑

现在我收到此错误:

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

我找到了此解决方案安装后无法运行WeasyPrint El Capitan(OSX 10.11),但不适用于OS X Yosemite.正在运行

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

未找到返回命令.

谢谢!

推荐答案

这里有同样的问题!我尝试安装pycairo,py2cairo.安装似乎还可以,但是然后:

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

  1. 我无法导入pycairo
  2. igraph的图不起作用


以下内容解决了igraph绘图问题:


The following solved the igraph plotting issue:

sudo pip install cairocffi

因此,我使用的是 cairocffi ,而不是pycairo.

So instead of pycairo I used cairocffi.

这篇关于Python igraph无法绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 10:40