I can't import igraph on mac 10.6

2019-08-06 03:37发布

问题:

I installed igraph for python in my mac but I can't import it. First I installed C core library, then I proceeded with the instalation for python, by doing:

python setup.py build
python setup.py install

Everything seemed to work fine but I can't import igraph from python shell. Just to clear up, I'm not inside igraph source code's folder. And I got this error:

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

I replaced my folder's name for *, so don't consider it.

I'm running python 2.7 over OS 10.6.7. So there's no pre-compiled version of igraph avaliable (2.5 and 2.6 only). Has this error anything to do with the python version I'm running? If possible, how can I work this out?

回答1:

I think the problem is that igraph is installed in /usr/local/lib/libigraph.dylib, but the linker cannot find it when Python tries to load the C core of the igraph module because /usr/local/lib is not on the default library path in Mac OS X. (At least I think so).

First, please check whether libigraph.dylib is really in /usr/local/lib - it should be there. After that, try this:

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

This should instruct the linker to look around in /usr/local/lib as well as the default places, and then run Python with the entire igraph test suite.