简体   繁体   English

OSError导入python-igraph

[英]OSError importing python-igraph

I am trying to import igraph but it keeps throwing this error at me: 我正在尝试导入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
  1. I have tried to follow this guide to install cairo but it throws this error and doesn't solve the igraph import issue: error: mandatory image surface backend feature could not be enabled 我尝试按照此指南安装cairo但会引发此错误,但不能解决igraph导入问题: error: mandatory image surface backend feature could not be enabled

  2. I have also tried to install pycairo but that resulted in no module founds: cairo , which brought me back to square one. 我也尝试安装pycairo但是no module founds: cairo ,这使我回到了第一位。

  3. I tried running sudo port install cairo as per https://cairographics.org/download/ instructions. 我尝试按照https://cairographics.org/download/的说明运行sudo port install cairo But that results in Error: Port cairo not found 但这导致Error: Port cairo not found


My sys config: 我的系统配置:

  • MacOS High Sierra 10.13.1 MacOS High Sierra 10.13.1
  • Python 3.6 Python 3.6
  • python-igraph 0.7.1 python-igraph 0.7.1

I am clueless as to what can be the issue. 我对可能出现的问题一无所知。 Any help would be highly appreciated. 任何帮助将不胜感激。 Thank you :) 谢谢 :)

Thanks to @Aiven I have managed to solve my issue. 感谢@Aiven,我设法解决了我的问题。 If anyone ever comes across the same problem, this have done the trick for me: 如果有人遇到过同样的问题,这对我来说就是成功的窍门:

brew install cairo
brew install py2cairo
brew install igraph  (install C-core)
sudo pip install python-igraph (install igraph for python)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM