在Mac上安装python igraph [英] Install python igraph on mac

查看:211
本文介绍了在Mac上安装python igraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I executed the brew install homebrew/science/igraph When I execute sudo pip3 install python-igraph, I got the following error

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>

任何人都可以帮忙吗? 非常感谢

Can anyone help? Many thanks

推荐答案

请注意,本文假定您具有自制软件已安装,并尝试在Mac上安装.

Note this post assumes you have homebrew installed and are trying to install on a Mac.

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

To avoid any issues of python3/python2 I would recommend using python2 because that is what the igraph library is designed to work with. I executed the following codes on a mac and things worked fine.

在python2上安装igraph的指令,在您的终端中执行以下几行:

Instructions to install igraph on python2, in your terminal execute these lines:

brew install cairo
brew install py2cairo
brew install igraph 

现在,该行上方的最后一行将安装C核.最终的终端线路是:

Now this last line above line installs the C-core. Final terminal line is:

sudo pip install python-igraph

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

The above line installs igraph for python2, note these lines take about 2 minutes to complete for me

接下来打开python2或idle-from终端(我使用过idle).

Next open python2 or idle-from terminal (I used idle).

现在检查python REPL shell ...

Mow check in python REPL shell...

import igraph.test
igraph.test.run_tests()

如果一切正常,那么您就可以在python中使用igraph了

If everything looks ok then you've got igraph in python working for you

也请检查以下一项:

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

您应该获得彼得森图的漂亮图形(红色节点,小图)

You should get a nice graphic of the peterson graph (red nodes, small graph)

这篇关于在Mac上安装python igraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆