1

我在我的 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 版本有什么关系吗?如果可能的话,我该如何解决这个问题?

4

1 回答 1

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。

于 2011-07-08T20:11:12.517 回答