我正在尝试导入igraph
,但它一直向我抛出此错误:
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/igraph/__init__.py",
line 36, in <module>
from igraph.clustering import *
File "/usr/local/lib/python3.6/site-packages/igraph/clustering.py",
line 36, in <module>
from igraph.drawing.colors import ClusterColoringPalette
File "/usr/local/lib/python3.6/site-
packages/igraph/drawing/__init__.py", line 27, in <module>
from igraph.drawing.graph import DefaultGraphDrawer
File "/usr/local/lib/python3.6/site-
packages/igraph/drawing/graph.py", line 27, in <module>
from igraph.drawing.edge import ArrowEdgeDrawer
File "/usr/local/lib/python3.6/site-packages/igraph/drawing/edge.py",
line 17, in <module>
cairo = find_cairo()
File "/usr/local/lib/python3.6/site-
packages/igraph/drawing/utils.py", line 413, in find_cairo
module = __import__(module_name)
File "/usr/local/lib/python3.6/site-packages/cairocffi/__init__.py",
line 41, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2')
File "/usr/local/lib/python3.6/site-packages/cairocffi/__init__.py",
line 38, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' /
'.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2
我已尝试按this guide安装cairo
,但它会引发此错误并且无法解决igraph
导入问题:error: mandatory image surface backend feature could not be enabled
我还尝试安装pycairo
,但结果是no module founds: cairo
,这让我回到原点。
我尝试按照https://cairographics.org/download/说明运行sudo port install cairo
。但这导致Error: Port cairo not found
我的系统配置:
我对这可能是什么问题毫无头绪。任何帮助将受到高度赞赏。谢谢:))
答案 0 :(得分:0)
感谢@Aiven我设法解决了我的问题。如果有人遇到同样的问题,这对我来说已经成功了:
brew install cairo
brew install py2cairo
brew install igraph (install C-core)
sudo pip install python-igraph (install igraph for python)