Fix Python graph-tool “couldn’t recognise svg” Problem

After I had installed graph-tool and gtk+3 via homebrew and tried to run a graph-tool demo, I came across the following problem:

I then did a little bit Googling and found out that this was caused by a lack of SVG lib ‘librsvg’ for homebrew’s gtk installation. However, a simple homebrew installation of that lib didn’t fix the problem. Lucky, I found this. It says that we need to refresh the gdk-pixbuf-query-loaders in order for gtk to recognise librsvg. Unfortunately, if you use homebrew’s librsvg (2.36.3), you will come across another problem:

Yes, we need to compile the newest librsvg:

1. Download librsvg-2.40.2 source code from here
2. Configure, make and install librsvg as follows:

Note that you may have to install more libs, such as libxml2, via homebrew.

3. Refresh gdk-pixbuf-query-loaders to load librsvg for gtk:

4. Enjoy graph-tool