【问题标题】:Installation of igraph on python distributed by anaconda ? (and graphviz)在 anaconda 分发的 python 上安装 igraph ? (和graphviz)
【发布时间】:2015-01-14 20:48:38
【问题描述】:

我尝试在 Anaconda 上安装 igraph 包,但到目前为止还没有成功。如果有人想办法得到它,我会很乐意尝试的!!下面是我尝试做的一些细节(如果你有在 Anaconda 上安装 igraph 的解决方案,你不必阅读它!)。

我使用的是 MAC OS X Yosemite(MAC book Pro 2,3 GHz Intel Core i7)。以下是一些配置参数: MBP-de-Lecue:site-packages lecueguillaume$ which python /用户/lecueguillaume/anaconda/bin/python MBP-de-Lecue:site-packages lecueguillaume$ which pip /Users/lecueguillaume/anaconda/bin/pip

igraph 应该通过 pip 安装。因为,当我输入 pip list 时,我可以在列表中看到包 igraph

python-igraph (0.7)

但是当我尝试在这里导入 igraph 时,我得到了:

MBP-de-Lecue:site-packages lecueguillaume$ python Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (默认,2014 年 8 月 21 日,15:21:46) [GCC 4.2.1 (Apple Inc. build 5577)] 在 darwin 上

导入 igraph 回溯(最近一次通话最后): 文件“”,第 1 行,在 文件“build/bdist.macosx-10.5-x86_64/egg/igraph/init.py”,第 34 行,在

文件“build/bdist.macosx-10.5-x86_64/egg/igraph/_igraph.py”,第 7 行,在 bootstrap 中的文件“build/bdist.macosx-10.5-x86_64/egg/igraph/_igraph.py”,第 6 行 ImportError:dlopen(/Users/lecueguillaume/.python-eggs/python_igraph-0.7-py2.7-macosx-10.5-x86_64.egg-tmp/igraph/_igraph.so,2):未加载库:libxml2.2.dylib 引用自:/Users/lecueguillaume/.python-eggs/python_igraph-0.7-py2.7-macosx-10.5-x86_64.egg-tmp/igraph/_igraph.so 原因:库版本不兼容:_igraph.so需要12.0.0或更高版本,而libxml2.2.dylib提供10.0.0版本

所以问题来自libxml2-2。我尝试使用 brew 升级 libxml: MBP-de-Lecue:site-packages lecueguillaume$ brew upgrade libxml2 错误:已经安装了 libxml2-2.9.2

1) 我不明白的第一件事是 libxml2.2 版本 12.0.0 似乎不存在。 http://xmlsoft.org 的最新版本是 9.2。那么为什么 igraph 要求版本 12.0 ? (我当然错过了什么)。

brew没有帮助的事实是因为它没有更新正确的libxml: MBP-de-Lecue:site-packages lecueguillaume$ which brew /usr/local/bin/brew

2) 我怎么能说 brew 来更新 anaconda/pkgs 中的 Anaconda libxml 库

3) 我还尝试使用 conda pipbuild python-igraph 安装图形。一切顺利:成功安装 python-igraph 除了它必须自己安装 igraph 的 C 核心,而我已经安装了它: 安装收集的包:python-igraph 为 python-igraph 运行 setup.py install 使用 pkg-config 在此系统上找不到 igraph 的 C 核心。 我们现在将尝试从头开始下载和编译 C 内核。 C核版本号:0.7 我们也会尝试:0.7.0

所以看起来 conda 安装运行良好,但“导入 igraph”仍然不起作用。

4) 最后,当我使用 python 的内置 MAC 版本时,igraph 运行良好: MBP-de-Lecue:site-packages lecueguillaume$ which python2.7 /opt/local/bin/python2.7 MBP-de-Lecue:站点包 lecueguillaume$ python2.7 Python 2.7.8(默认,2014 年 7 月 13 日,17:11:32) [GCC 4.2.1 兼容 Apple LLVM 5.1 (clang-503.0.40)] 在 darwin 输入“help”、“copyright”、“credits”或“license”了解更多信息。

导入 igraph

所以 igraph 在 python 的 MAC 版本中安装得很好,但在 Anaconda 版本中没有。由于我使用 Anaconda Notebook(可与 Anaconda python 配合使用),因此我想在其上安装 igraph。

抱歉,问题太长了(这是我第一次提出问题)。我对graphviz包也有同样的问题(安装在MAC python2.7版本上,但没有安装在Anaconda python版本上)。

非常感谢您的帮助!

纪尧姆。

【问题讨论】:

    标签: macos python-2.7 igraph anaconda pygraphviz


    【解决方案1】:

    好的,这里有多个问题,所以我会尝试一一回答。

    1. 您看到的版本号与 libxml2 的“官方”版本号(顺便说一下,在撰写本文时是 2.9.2 而不是 9.2)无关。这是库的应用程序二进制接口 (ABI) 的版本号。一些项目选择使 ABI 的版本号与库的“公共”版本号保持同步,但这不是必需的。您可以使用otool -L 在 Mac 上查看库的 ABI 版本;例如,otool -L /usr/lib/libxml2.2.dylib 在我的 Mac 上给了我current version 10.9.0

      现在,您的系统上似乎有多个libxml2 副本。一个来自 OS X 本身,位于/usr/lib。另一个是从 brew 安装的 - 这是在 /usr/local/lib 的某个地方。也许还有第三个来自 Anaconda Python。问题是 igraph 在编译时链接到其中一个(使用 ABI 版本 12.0.0),但是当您尝试导入 igraph 时,系统找不到这个 libxml2 并尝试链接到另一个使用 ABI 版本 10.0 的文件.0 代替。由你来解决这个问题。首先,我会在您的机器上查找所有出现的libxml2*.dylib 并在所有机器上运行otool -L,以查看哪个具有ABI 版本12.0.0 - 这是igraph 链接到的那个。然后你可以尝试在编译和安装 igraph 时临时重命名这个库(以防止链接器找到它并链接到它),并在安装完成后重命名它。这样,您可能能够获得链接到 libxml2 的“正确”版本的 igraph 的编译版本。

    2. Brew 不会安装来自 Anaconda Python 的 libxml2,这是正确的 - 通常让一个软件(即 Brew)与另一个软件(即Anaconda Python)。

    3. igraph 在编译期间尝试使用pkg-config 查找其C 内核;特别是,它执行pkg-config --cflags --libs igraph。这对你有用吗?

    【讨论】:

    • @guillaume lecue:我不得不恢复你的编辑;请提供我要求的任何额外信息,方法是编辑您的自己的帖子(不是我的答案)或在我的帖子下方添加评论(假设您有足够的代表来做)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-13
    • 2018-02-08
    • 1970-01-01
    • 2016-01-30
    • 1970-01-01
    • 2016-09-13
    相关资源
    最近更新 更多