Installation of igraph on python distributed by anaconda ? (and graphviz)

1.7k views Asked by At

I tried to install the package igraph on Anaconda but so far it did not work. If anyone find a way to get it, I would be very happy to try it !! Below are some details of what I tried to do (if you have the solution of installing igraph on Anaconda, you don't have to read it!).

I'm on MAC OS X Yosemite (MAC book Pro 2,3 GHz Intel Core i7). Here are some configuration parameters: MBP-de-Lecue:site-packages lecueguillaume$ which python /Users/lecueguillaume/anaconda/bin/python MBP-de-Lecue:site-packages lecueguillaume$ which pip /Users/lecueguillaume/anaconda/bin/pip

igraph is supposed to be installed via pip. Since, when I typed pip list, I can see the package igraph in the list

python-igraph (0.7)

But when I try to import igraph here is what I get:

MBP-de-Lecue:site-packages lecueguillaume$ python Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin

import igraph Traceback (most recent call last): File "", line 1, in File "build/bdist.macosx-10.5-x86_64/egg/igraph/init.py", line 34, in

File "build/bdist.macosx-10.5-x86_64/egg/igraph/_igraph.py", line 7, in File "build/bdist.macosx-10.5-x86_64/egg/igraph/_igraph.py", line 6, in bootstrap ImportError: dlopen(/Users/lecueguillaume/.python-eggs/python_igraph-0.7-py2.7-macosx-10.5-x86_64.egg-tmp/igraph/_igraph.so, 2): Library not loaded: libxml2.2.dylib Referenced from: /Users/lecueguillaume/.python-eggs/python_igraph-0.7-py2.7-macosx-10.5-x86_64.egg-tmp/igraph/_igraph.so Reason: Incompatible library version: _igraph.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

So the problem comes from libxml2-2. I tried to upgrade libxml with brew: MBP-de-Lecue:site-packages lecueguillaume$ brew upgrade libxml2 Error: libxml2-2.9.2 already installed

1) The first thing that I don't get is that libxml2.2 version 12.0.0 does not seem to exist. The latest version on http://xmlsoft.org is 9.2. So why igraph is asking for version 12.0 ? (I certainly missed something).

The fact that brew does not help is because it does not update the right libxml: MBP-de-Lecue:site-packages lecueguillaume$ which brew /usr/local/bin/brew

2) How can I say to brew to update the Anaconda libxml library in anaconda/pkgs

3) I also tried to install graph with conda pipbuild python-igraph. Everything went well : Successfully installed python-igraph Except that it had to install the C Core of igraph by itself whereas I already installed it: Installing collected packages: python-igraph Running setup.py install for python-igraph Cannot find the C core of igraph on this system using pkg-config. We will now try to download and compile the C core from scratch. Version number of the C core: 0.7 We will also try: 0.7.0

So it looks like the conda installation worked well but the "import igraph" still does not work.

4) Finally, when I use the built-in MAC version of python, igraph works well: MBP-de-Lecue:site-packages lecueguillaume$ which python2.7 /opt/local/bin/python2.7 MBP-de-Lecue:site-packages lecueguillaume$ python2.7 Python 2.7.8 (default, Jul 13 2014, 17:11:32) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import igraph

So igraph was well installed in the MAC version of python but not in the Anaconda version. Since I use Anaconda Notebook (which works wit Anaconda python), I would like to have igraph installed on it.

Sorry for the long question (this is the first time I asked a question). I have the very same problem with the package graphviz (installed on MAC python2.7 version but not on Anaconda python's version).

Many thanks in advance for any help !

Guillaume.

1

There are 1 answers

1
Tamás On

Okay, there are multiple questions here so I'll try to answer them one by one.

  1. The version number that you see there has nothing to do with the "official" version number of libxml2 (which is, by the way, 2.9.2 at the time of writing and not 9.2). This is the version number of the Application Binary Interface (ABI) of the library. Some projects choose to keep the version number of the ABI in sync with the "public" version number of the library, but this is not required. You can check the ABI version of a library on Mac with otool -L; e.g., otool -L /usr/lib/libxml2.2.dylib gives me current version 10.9.0 on my Mac.

    Now, it seems to be the case that there are multiple copies of libxml2 on your system. One comes from OS X itself, this is in /usr/lib. Another one is installed from brew - this is somewhere in /usr/local/lib. And maybe there's a third one from Anaconda Python. The problem is that igraph was linked to one of these (with ABI version 12.0.0) while it was compiled, but when you try to import igraph, the system does not find this libxml2 and tries to link to another one with ABI version 10.0.0 instead. It is up to you to sort this out. First, I would look for all occurrences of libxml2*.dylib on your machine and run otool -L on all of them to see which one has ABI version 12.0.0 - this is the one that igraph was linked to. Then you could try to rename this library temporarily while compiling and installing igraph (to prevent the linker from finding it and linking to it), and rename it back after the installation finished. This way you may be able to obtain a compiled version of igraph that links to the "right" version of libxml2.

  2. Brew will not install libxml2 that comes from Anaconda Python, and rightly so - it is in general a bad idea to let one piece of software (i.e. Brew) mess around with the dependencies of another piece of software (i.e. Anaconda Python).

  3. igraph tries to find its C core using pkg-config during compilation time; in particular, it executes pkg-config --cflags --libs igraph. Does this work for you from the command line?