Syed Arefinul Haque
Syed Arefinul Haque

Reputation: 1335

Install python-igraph in Mac OSX Sierra

I have anaconda installed in my Mac. I am trying to install python-igraph.

I tried the following commands to install it:

$ brew install igraph
$ pip install python-igraph

My python setup:

Python 2.7.13 |Anaconda custom (x86_64)| (default, Dec 20 2016, 23:05:08) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin`
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

But when I try to import igraph, I get the following error:

>>> import igraph

Traceback (most recent call last):

File "", line 1, in

File "/Users/arefindk/anaconda2/lib/python2.7/site-packages/igraph/init.py", line 34, in

from igraph._igraph import *

ImportError: dlopen(/Users/arefindk/anaconda2/lib/python2.7/site-packages/igraph/_igraph.so, 2): Symbol not found: _iconv

Referenced from: /Users/arefindk/anaconda2/lib/python2.7/site-packages/igraph/_igraph.so

Expected in: flat namespace

in /Users/arefindk/anaconda2/lib/python2.7/site-packages/igraph/_igraph.so

Now, I have tried to follow all the steps that is provided in this answer.

My hunch is, it might be a problem related to Anaconda because my friend successfully installed and imported python-igraph using the above commands and he doesn't have Anaconda installed.

How can I both solve this problem and keep Anaconda in my Mac?

Upvotes: 1

Views: 1634

Answers (2)

John Miller
John Miller

Reputation: 21

Yes, the conda install -c conda-forge python-igraph worked fine for me, after many other attempts to install in macOS mojave. Also worth remembering to search the anaconda site https://anaconda.org/search?q=igraph

Upvotes: 2

deeenes
deeenes

Reputation: 4586

You've attempted 2 different ways, neither of them is supposed to work with Anaconda. First, on Mac igraph can not be installed simply by pip because it fails to compile the underlying C bindings. Second, the Python distribution installed and managed by brew is usually independent from the one of Anaconda. Actually you might have already igraph in your brew managed Python, but then you need to call that Python not the Anaconda one. Assuming you have other ties to Anaconda and you want to stick to that distribution, you need to look for packages in official or unofficial Anaconda repositories. In order to have igraph with plotting functionality, you need the followings:

  • the igraph C library
  • python-igraph for Python 2.7
  • cairo 1.12 (C library)
  • py2cairo

Here I show you the versions that worked for me few months ago:

conda install -y -c vgauthier cairo=1.12.18
conda install -y -c pkgw py2cairo
# if you want it for Python 3:
# conda install -y -c richlewis pycairo=1.10.0
conda install -y -c bioconda python-igraph

If the above doesn't work for you, search for other package options in the Anaconda repositories, like this one.

Upvotes: 2

Related Questions