Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install graph-tool on Mac OS Mavericks with python installed with brew

Install prerequisites

Install Homebrew

Install Python

  • brew install python
  • vim ~/.bash_profile
  • and insert this code:

Set architecture flags

export ARCHFLAGS="-arch x86_64"

Ensure user-installed binaries take precedence

export PATH=/usr/local/bin:$PATH

Load .bashrc if it exists

test -f ~/.bashrc && source ~/.bashrc

  • . ~/.bash_profile
  • easy_install pip # If you don't have already pip installed

Install libraries and prerequisites

  • brew install gcc
  • pip install numpy
  • pip install scipy
  • brew install freetype
  • pip install matplotlib

Install graph-tool with brew

  • brew tap homebrew/science
  • brew install graph-tool

Note: google-sparsehash is not required, and a couple people are having trouble compiling google-sparsehash on OSX 10.9

You can skip installing google-sparsehash. Just make sure you run ./configure PYTHON_EXTRA_LDFLAGS="-L/usr/local/bin" --disable-sparsehash and the configure script won't look for the sparsehash headers.

The problem of googol-sparsehash in OSX 10.9 can be solved by using
brew install google-sparsehash --cc=gcc-4.2


ghost commented Apr 15, 2014

A tool so impossible to install is a real dissuasion from use.

juliusf commented Jun 26, 2014

Note: when compiling boost, please not that the python bindings are not included by default anymore. This can be solved by using:
brew install --with-c++11 --build-from-source boost -v --with-python

Installing on a new machine and running into more issues. For some reason, this time around the configure script couldn't find the headers and libraries for boost, so I had to solve via export CPPFLAGS="-I/usr/local/Cellar/boost/1.55.0_2/include -L/usr/local/Cellar/boost/1.55.0_2/lib"

homebrew has a separate boost for python now
brew install --with-c++11 --build-from-source boost-python

If you stumple into problems with cairo dependencies, take a look at this issue Homebrew/homebrew#14123

brew install --with-c++11 --build-from-source boost-python did not work for me, but this thread helped instead.

Now the problem is that make fails with the following message:

ld: library not found for -lCGAL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

wah commented Nov 20, 2014

I've had a hell of a time installing this, but I think I finally have it working. Some other dependencies available on Homebrew that aren't mentioned above are:

  • gtk+3
  • gdk-pixbuf
  • librsvg
  • pygobject
  • hicolor-icon-theme

I installed all of these after running make install on graph-tool itself. I'm pretty sure there were others, but I lost count. I also had problems with interactive graphs crashing at runtime because of a missing icon called 'system-run' in GTK. I got around this by putting a file called system-run.png in /usr/share/icons/ and giving read permission to all.

I was able to configure after brew installing / rebuilding boost from scratch, as described here (mentioned by others above):

When I tried to make, I found the following error:

./../numpy_bind_old.hh:58:65: error: 'value' is not a member of 'boost::mpl::aux::wrapped_typeboost::mpl::aux::type_wrapper<mpl_::void_ >::type {aka mpl_::void_}'
int val_type = boost::mpl::at<numpy_types,ValueType>::type::value;

As also described here:

I switched my python binary to point to "/usr/bin/pythonw2.7" based on the link, which took me a couple hours to find (note: that is version Python 2.7.5 (default, Mar 9 2014, 22:15:05)), as described in the link. Previously, I was using Python 3.4.1 (default, May 19 2014, 13:10:29). Using the pythonw2.7 binary still didn't seem to help. It looks to me like there is some boost compatibility issue. Anybody else seeing this?

munum commented Jan 25, 2015

For now it is brew install boost-python.

stared commented Apr 6, 2015

This is a rather long list. What is wrong with using direct recipe from ?

$ brew tap homebrew-science
$ brew install graph-tool

It did work for me (I had brew-installed Python, and XCode).

Use that one, please.
$ brew tap homebrew/science
$ brew install graph-tool


openp2pdesign commented Sep 7, 2015

This gist is an old solution, that was also featured on the graph-tool website back then.
But now the best solution is the official one with Brew, which came later:

$ brew tap homebrew-science
$ brew install graph-tool


openp2pdesign commented Sep 7, 2015

I've updated the file to the current process.

aa21 commented Dec 24, 2017

Ending 2017, this worked perfectly for me.

Edit: 1 Week later - NO it doesn't work. I spoke far far too soon. When I try to run a simple script with graph-tool it crashes. I'm not even back to square one, I'm at square -15. Seriously thinking of abandoning graph-tool and heading for NetworkX or iGraph. Shame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment