0
votes

On importing igraph in python, I get an error (see below). Since igraph is not part of anaconda, I executed the below outlined steps for installation.

What is libglpk.35.dylib, how should I load it, and why is this problem occurring?

igraph cannot be imported

'' import igraph
'' Traceback (most recent call last):
''   File "<stdin>", line 1, in <module>
''   File "/Users/claushaslauer/anaconda/lib/python2.7/site-packages/igraph/__init__.py", line 34, in <module>
    '' from igraph._igraph import *
'' ImportError: dlopen(/Users/claushaslauer/anaconda/lib/python2.7/site-packages/igraph/_igraph.so, 2): Library not loaded: /usr/local/lib/libgmp.10.dylib
''   Referenced from: /usr/local/lib/libglpk.35.dylib
''   Reason: image not found

installation steps

  1. install homebrew via ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. install pkg-config (via igraph-help) brew install pkg-config
  3. install igraph via homebrew: brew install igraph
  4. link: brew install homebrew/science/igraph
  5. pip install python-igraph

following suggestions from Evert:

  1. brew uninstall igraph
  2. brew uninstall gmp
  3. brew uninstall glkp -- Error: No such keg: /usr/local/Cellar/glkp
  4. brew install igraph

    ==> Installing igraph from homebrew/homebrew-science ==> Installing igraph dependency: gmp ==> Downloading https://homebrew.bintray.com/bottles/gmp-6.0.0a.yosemite.bottle. Already downloaded: /Library/Caches/Homebrew/gmp-6.0.0a.yosemite.bottle.tar.gz ==> Pouring gmp-6.0.0a.yosemite.bottle.tar.gz Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink include/gmp.h Target /usr/local/include/gmp.h already exists. You may want to remove it: rm '/usr/local/include/gmp.h'

    To force the link and overwrite all conflicting files: brew link --overwrite gmp

    To list all files that would be deleted: brew link --overwrite --dry-run gmp

    Possible conflicting files are: /usr/local/include/gmp.h /usr/local/lib/libgmp.a ==> Summary ???? /usr/local/Cellar/gmp/6.0.0a: 15 files, 3.2M ==> Installing igraph ==> Downloading https://homebrew.bintray.com/bottles-science/igraph-0.7.1.yosemi Already downloaded: /Library/Caches/Homebrew/igraph-0.7.1.yosemite.bottle.tar.gz ==> Pouring igraph-0.7.1.yosemite.bottle.tar.gz ???? /usr/local/Cellar/igraph/0.7.1: 83 files, 6.4M

    • what does "Error: The brew link step did not complete successfully" imply?
    • I don't see anything related to /usr/local/lib/libglpk.35.dylib -- when I call python now, the same error occurs as before.

Solution with Evert's help

thanks Evert for the additional answer. With this content, I can import igraph now. Three things to note:

  1. When I say brew tap homebrew/sciene, log in with my github credentials, I get

    remote: Repository not found.
    fatal: repository 'https://github.com/Homebrew/homebrew-sciene/' not found
    Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-sciene /usr/local/Library/Taps/homebrew/homebrew-sciene --depth=1 
    

    I am not sure how critical this is, as it turned out, I can run igraph without this. However, the URL https://github.com/Homebrew/homebrew-sciene/ produces a 404 error for me.

  2. brew search glpk and brew search igraph both return the one line output pointing to homebrew/science/...

  3. brew link --overwrite gmp says it created 11 symlinks. I think this is what solved my issue so now I can import igraph fine in python.

Thanks for your help.

1
Are there any warnings or errors when you run pip install python-igraph? Or at brew install igraph?user707650
libglpk.35.dylib is a dependency library for igraph; it should get automatically installed when you brew install igraph (it does for me). Ditto libgmp.10.dylib.user707650
Try uninstalling igraph (brew uninstall igraph), as well as the dependencies (gmp, glkp), then reinstall and copy-paste the log into your question. My log shows that running brew install igraph installs gmp-6.0.0a.yosemite.bottle.tar.gz and glpk-4.52.yosemite.bottle.1.tar.gz, for example.user707650
We'll solve the linking problem later, but could you try just brew install glpk: installing the missing dependency. I'd like to know what error homebrew gives there.user707650
you misspelled scienceuser3067923

1 Answers

3
votes

The glpk dependency is missing, because when installing igraph, only the default packages are searched for. glpk lives, just like igraph, in an extra homebrew repository called homebrew/science. You can automatically access that repository by "tapping" it:

brew tap homebrew/science

Now, all packages included in this repository are also searched for. To confirm, try and see if the following two commands give just the package name back:

brew search glpk

brew search igraph

Before reinstalling igraph, you have to fix the link issue with gmp; this is just a result of homebrew not completely uninstalling igraph and its dependencies during the uninstall step. For this, you can follow homebrew's suggestion:

brew link --overwrite gmp

(You're overwriting the gmp package with the previously and still partly installed gmp package; they are the same, so no harm is done.)


Now, you should be able to install igraph:

brew install igraph

If this also gives a warning/error about links, use the same --overwrite option as for gmp.

In case brew install igraph did not install glpk (i.e., you didn't see a message like "==> Installing igraph dependency: glpk"), you can simply install it separately:

brew install glpk

Give or take a minor detail, you should now have a working igraph installation (and, since you never uninstalled python-igraph, this should also still work).