ImportError when importing igraph

Asked by Timo Smieszek

Hi!

I use a MacBook Pro with OS X Lion and the Enthought Python Distribution 2.7.2; after installing igraph I tried to import it. I got the following error message:

Python 2.7.2 |EPD 7.2-2 (32-bit)| (default, Sep 7 2011, 09:16:50)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "packages", "demo" or "enthought" for more information.
>>> import igraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/igraph/__init__.py", line 34, in <module>
    from igraph._igraph import *
ImportError: dlopen(/Library/Python/2.7/site-packages/igraph/_igraph.so, 2): Symbol not found: _igraph_eit_destroy
  Referenced from: /Library/Python/2.7/site-packages/igraph/_igraph.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/igraph/_igraph.so

What went wrong and how can it be fixed?

Thank you for your help!

Timo

Question information

Language:
English Edit question
Status:
Answered
For:
igraph Edit question
Assignee:
Tamás Nepusz Edit question
Last query:
Last reply:
Revision history for this message
Tamás Nepusz (ntamas) said :
#1

Can you please check whether you have a file named /usr/local/lib/libigraph.dylib on your machine? Also, can you try importing igraph from the "default" Python (/usr/bin/python) and not the one that comes with EPD?

Revision history for this message
Timo Smieszek (smieszek) said :
#2

Thank you for the immediate reply.
Answer 1) The file is called /usr/local/lib/libigraph.0.dylib on my machine not /usr/local/lib/libigraph.dylib
Answer 2) It is no problem with the default Python, but it still is with the Enthought distribution.

Revision history for this message
Tamás Nepusz (ntamas) said :
#3

Okay. I presume that you have used the Mac OS X installer for igraph that is published on the Python Package Index. This installer is designed for the "default" Python on Mac OS X and has not been tested with EPD. For me it seems like EPD is not able to find _igraph_eit_destroy, which is a symbol that comes from /usr/local/lib/libigraph.0.dylib.

I have a few ideas here but I cannot test them as I don't have EPD on my machine. Basically they all boil down to "telling" EPD to look for lbiigraph.0.dylib in /usr/local/lib. I'll download EPD and get back to you when I figured it out.

Revision history for this message
Tamás Nepusz (ntamas) said :
#4

Can you please run the following command?

file /usr/local/lib/libigraph.0.dylib

Revision history for this message
Timo Smieszek (smieszek) said :
#5

Thank you!

Revision history for this message
Timo Smieszek (smieszek) said :
#6

Done.
Prints the following output on my screen:

client-75-102-84-229:bin timosmieszek$ file /usr/local/lib/libigraph.0.dylib
/usr/local/lib/libigraph.0.dylib: Mach-O universal binary with 2 architectures
/usr/local/lib/libigraph.0.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/lib/libigraph.0.dylib (for architecture i386): Mach-O dynamically linked shared library i386

Revision history for this message
Tamás Nepusz (ntamas) said :
#7

Okay, that's great. My worry was that libigraph.0.dylib was somehow built for 64-bit architectures only, but apparently this is not the case here. Can you also send me the output of the following commands:

file /Library/Python/2.7/site-packages/igraph/_igraph.so
otool -L /Library/Python/2.7/site-packages/igraph/_igraph.so

Revision history for this message
Timo Smieszek (smieszek) said :
#8

file /Library/Python/2.7/site-packages/igraph/_igraph.so

/Library/Python/2.7/site-packages/igraph/_igraph.so: Mach-O universal binary with 2 architectures
/Library/Python/2.7/site-packages/igraph/_igraph.so (for architecture i386): Mach-O bundle i386
/Library/Python/2.7/site-packages/igraph/_igraph.so (for architecture x86_64): Mach-O 64-bit bundle x86_64

otool -L /Library/Python/2.7/site-packages/igraph/_igraph.so

/Library/Python/2.7/site-packages/igraph/_igraph.so:
 /Users/ntamas/lib/libigraph.0.dylib (compatibility version 1.0.0, current version 1.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

Revision history for this message
Tamás Nepusz (ntamas) said :
#9

Damn. Thanks for the heads up. Note that _igraph.so tries to load libigraph.0.dylib from /Users/ntamas/lib, which is a folder on _my_ machine. I will post an updated installer on PyPI soon.

Revision history for this message
Tamás Nepusz (ntamas) said :
#10

In the meanwhile, you could try modifying the dependent library path in _igraph.so as follows:

install_name_tool -change /Users/ntamas/lib/libigraph.0.dylib /usr/local/lib/libigraph.0.dylib /Library/Python/2.7/site-packages/igraph/_igraph.so

Not sure if this will work, though.

Revision history for this message
Timo Smieszek (smieszek) said :
#11

Such things happen ;-)
Pls. keep me posted when the updated version is available...

Revision history for this message
Timo Smieszek (smieszek) said :
#12

no, it didn't

Revision history for this message
Tamás Nepusz (ntamas) said :
#13

The issue is now resolved and the fixed installers are uploaded to PyPI. Thanks for the quick feedback!

Can you help with this problem?

Provide an answer of your own, or ask Timo Smieszek for more information if necessary.

To post a message you must log in.