python-igraph图不可用(已安装开罗) [英] python - igraph plot not available (cairo already installed)
问题描述
我已经使用brew安装了py2cairo,但是在尝试使用igraph进行绘制时总是出现错误.我收到以下错误:
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
在Anaconda Python下运行igraph时,
推荐答案
brew
可能会为其自己的Python安装py2cairo
.在您的计算机上为一个Python发行版安装的模块不会在其他Python发行版下神奇地出现,因此对于Anaconda Python,您将必须获取py2cairo
;对于Homebrew的Python,则必须编译igraph的Python接口.
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.
这篇关于python-igraph图不可用(已安装开罗)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!