我无法在mac 10.6上导入igraph

时间:2011-07-07 03:05:52

标签: macos import python-2.7 igraph

我在我的mac中为python安装了igraph但我无法导入它。首先我安装了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版本有什么关系吗? 如果可能的话,我该如何解决这个问题?

1 个答案:

答案 0 :(得分: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。