【问题标题】:Install python igraph on mac在mac上安装python igraph
【发布时间】:2017-09-21 11:55:21
【问题描述】:

我执行了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>

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

【问题讨论】:

标签: python igraph


【解决方案1】:

请注意,本文假设您已安装 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或idle-from终端(我用idle)。

在 python REPL shell 中检查...

import igraph.test
igraph.test.run_tests()

如果一切正常,那么你已经在 python 中为你工作了 igraph

也检查一下这个:

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

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

【讨论】:

  • 我遵循了你的指导方针,但我遇到了这个错误:ImportError: dlopen(/Users/alexandreattia/Desktop/Work/py27_venv/lib/python2.7/site-packages/igraph/_igraph.so, 2): Symbol not found: _iconv Referenced from: /Users/alexandreattia/Desktop/Work/py27_venv/lib/python2.7/site-packages/igraph/_igraph.so Expected in: flat namespace in /Users/alexandreattia/Desktop/Work/py27_venv/lib/python2.7/site-packages/igraph/_igraph.so 你知道如何解决它吗?
  • 您是否安装了自制软件并且您使用的是 Mac?请提供您调用的导致错误的命令,而不仅仅是错误,这将对我有所帮助。
  • 是的,我在 Mac (High Sierra) 上,我有自制软件 (1.3.6)。我在 python 2.7 import igraph 上运行时创建了此错误。非常感谢
  • 嗯,我要做的第一件事是查看 Homebrew 在您的机器上安装 igraph 时的日志。我的第一个猜测是 homebrew 使用的位置与你的 python 2.7 环境使用的位置不同。
  • 解决此问题的最简单方法是使用 homebrew 使用的 python 环境,而不是其他选项。为此,您可以在终端中通过简单的 python 调用来获取 REPL shell。
猜你喜欢
  • 1970-01-01
  • 2017-08-10
  • 2017-03-19
  • 1970-01-01
  • 2016-08-01
  • 1970-01-01
  • 2021-11-15
  • 2021-04-14
  • 2013-07-10
相关资源
最近更新 更多