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
- install homebrew via
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- install pkg-config (via igraph-help)
brew install pkg-config
- install igraph via homebrew:
brew install igraph
- link:
brew install homebrew/science/igraph
pip install python-igraph
following suggestions from Evert:
brew uninstall igraph
brew uninstall gmp
brew uninstall glkp
--Error: No such keg: /usr/local/Cellar/glkp
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
The
glpk
dependency is missing, because when installingigraph
, only the default packages are searched for.glpk
lives, just likeigraph
, in an extra homebrew repository called homebrew/science. You can automatically access that repository by "tapping" it: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:
Before reinstalling
igraph
, you have to fix the link issue withgmp
; this is just a result of homebrew not completely uninstallingigraph
and its dependencies during the uninstall step. For this, you can follow homebrew's suggestion:(You're overwriting the
gmp
package with the previously and still partly installedgmp
package; they are the same, so no harm is done.)Now, you should be able to install igraph:
If this also gives a warning/error about links, use the same
--overwrite
option as forgmp
.In case
brew install igraph
did not installglpk
(i.e., you didn't see a message like "==> Installing igraph dependency: glpk"), you can simply install it separately: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).