Install python igraph on mac

ぃ、小莉子 提交于 2019-12-23 23:01:25

问题


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


回答1:


Note this post assumes you have homebrew installed and are trying to install on a 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.

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

brew install cairo
brew install py2cairo
brew install igraph 

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

sudo pip install python-igraph

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

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

Mow check in python REPL shell...

import igraph.test
igraph.test.run_tests()

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

Also check this one:

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

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



来源:https://stackoverflow.com/questions/45667147/install-python-igraph-on-mac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!