python - 在 Mac 上安装 python igraph

标签 python igraph

我执行了brew install homebrew/science/igraph 当我执行sudo pip3 install python-igraph时,出现以下错误

Cannot find the C core of igraph on this system using pkg-config.
We will now try to download and compile the C core from scratch.
Version number of the C core: 0.7.1.post6
We will also try: 0.7.1

Using temporary directory: /private/tmp/pip-build-35vcjf7l/python-igraph/tmp/igraph.4cz7yjcl
Downloading igraph-0.7.1.tar.gz... 0.28%error: <urlopen error retrieval incomplete: got only 992 out of 2967134 bytes>

有人可以帮忙吗? 非常感谢

最佳答案

请注意,这篇文章假设您有 homebrew已安装并正在尝试在 Mac 上安装。

为了避免 python3/python2 的任何问题,我建议使用 python2,因为这就是 igraph 库的设计目的。我在 Mac 上执行了以下代码,一切正常。

在 python2 上安装 igraph 的说明,在终端中执行以下行:

brew install cairo
brew install py2cairo
brew install igraph 

现在上面的最后一行安装了 C 核心。最终终端线是:

sudo pip install python-igraph

上面的行为python2安装了igraph, 请注意,我大约需要 2 分钟才能完成这些行

接下来打开 python2 或空闲终端(我使用空闲)。

在 python REPL shell 中检查一下...

import igraph.test
igraph.test.run_tests()

如果一切看起来都正常,那么你已经有了 python 中的 igraph 为你工作

另请检查这一点:

from igraph import *
g = Graph.Famous("petersen")
plot(g)

您应该得到一个漂亮的彼得森图(红色节点,小图)

关于python - 在 Mac 上安装 python igraph,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45667147/

相关文章:

r - 删除igraph R中顶点之间的边

python - 为什么 Thrift Binary 协议(protocol)序列化这么慢?

python - django imagefield上传总是提示没有选择文件

python - Pandas 按名称和最近日期合并

使用 igraph 对象递归循环邻居

r - 并排输出维恩 gList 对象和网络图

python - 如何识别 Selenium 中偶尔出现的文本

python - Python 中的 "List index out of range"错误

c++ - 迭代 boost multi_index

r - 将数据框转换为边缘列表