【问题标题】:I can't import igraph on mac 10.6我无法在 mac 10.6 上导入 igraph
【发布时间】:2011-07-07 03:05:52
【问题描述】:

我在我的 mac 中安装了 igraph for python,但我无法导入它。首先我安装了 C 核心库,然后我继续安装 python,方法是:

python setup.py build
python setup.py install

似乎一切正常,但我无法从 python shell 导入 igraph。澄清一下,我不在 igraph 源代码的文件夹中。我得到了这个错误:

import igraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.3-fat/egg/igraph/__init__.py", line 30, in <module>

  File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 7, in <module>
  File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so, 2): Symbol not found: _igraph_vector_destroy
  Referenced from: /Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so
  Expected in: dynamic lookup

我用 * 替换了我的文件夹名称,所以不要考虑。

我在 OS 10.6.7 上运行 python 2.7。所以没有可用的 igraph 预编译版本(仅限 2.5 和 2.6)。这个错误与我正在运行的 python 版本有什么关系吗? 如果可能,我该如何解决?

【问题讨论】:

  • 你在哪里安装了igraph的C核?它是否在链接器可以找到的某个标准位置?您的机器上是否有任何其他安装的核心库(旧版本)可能会混淆链接器?
  • 其实我之前没有安装过核心库。我认为 C 核心安装在标准位置,因为我没有指定任何位置。我刚刚做了:./configure 然后make 然后make install ()。我想在哪里安装它?如果要更改安装位置,如何设置安装C核心的路径以及如何删除安装在错误目录中的路径? (我是mac的初学者,对不起)
  • 通常的./configure &amp;&amp; make &amp;&amp; make install dance应该在/usr/local/lib/libigraph.dylib中安装igraph,应该没问题。你确定你下载编译的igraph内核的版本号和Python接口的版本号一致吗?
  • 我已经下载并安装了 sourceforge 的最新版本 0.5.4。我的 Python 接口的版本号是 2.7。

标签: macos import python-2.7 igraph


【解决方案1】:

我认为问题是 igraph 安装在/usr/local/lib/libigraph.dylib 中,但是当 Python 尝试加载 igraph 模块的 C 核心时链接器找不到它,因为/usr/local/lib 不在 Mac OS X 中的默认库路径上.(至少我是这么认为的)。

首先,请检查libigraph.dylib 是否真的在/usr/local/lib - 它应该在那里。之后,试试这个:

DYLD_LIBRARY_PATH=/usr/local/lib python -m igraph.test.__init__

这应该指示链接器在 /usr/local/lib 以及默认位置四处查看,然后使用整个 igraph 测试套件运行 Python。

【讨论】:

  • 太棒了。如果您想保留这些更改,请在您的主目录中编辑您的 .profile 文件,如下所示:export DYLD_LIBRARY_PATH=/usr/local/lib
猜你喜欢
  • 2012-02-29
  • 2017-05-30
  • 2011-10-05
  • 2011-06-11
  • 2016-04-20
  • 1970-01-01
  • 2017-03-05
  • 2012-01-31
  • 2012-03-18
相关资源
最近更新 更多