请注意,这篇文章假设您有homebrew https://brew.sh/已安装并正在尝试在 Mac 上安装。
为了避免 python3/python2 的任何问题,我建议使用 python2,因为这就是 igraph 库的设计目的。我在 Mac 上执行了以下代码,一切正常。
在 python2 上安装 igraph 的说明,在终端中执行以下行:
brew install cairo
brew install py2cairo
brew install igraph
现在,上面的最后一行安装了 C 核心。最终终端线是:
sudo pip install python-igraph
上面的行安装了 igraphpython2,
请注意,我大约需要 2 分钟才能完成这些行
接下来打开 python2 或空闲终端(我使用空闲)。
看看 python REPL shell 中的情况...
import igraph.test
igraph.test.run_tests()
如果一切看起来都正常,那么你已经有了 python 中的 igraph 为你工作
另请检查这一点:
from igraph import *
g = Graph.Famous("petersen")
plot(g)
您应该得到一个漂亮的彼得森图(红色节点,小图)