3

Hello stack community!

I'm not sure if my question is graph-tool related or gtk-related, but maybe both. Moreover, sorry if what I did while trying to solve it is plain stupid, I'm not a programmer by formal education, so I know just as much as I could find by google and comprehend.

Here is the problem: After I brew install graph-tool, launch python and try to import graph_tool.all I get the following error:

/usr/local/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py:1318: RuntimeWarning: Error importing Gtk module: No module named repository; GTK+ drawing will not work.

Previously I was sure that if import pygtk; pygtk.require('2.0'); import gtk works, that means the error is a graph-tool issue, but that don't have to be the case since graph-tool might use gtk (3??) and GObject (right?) and the upper checks for gtk2 and pygtk ( This question led me to this thought ). I tried reinstalling gtk, GObject and all dependencies. Wipe all brew-related and brew itself and then reinstall everything (as in here). Still same error appears. I also tried to unlink everything from brew and link it again just to be sure, but this does not change anything either.

What else did I check:

I'm running MAC OS X Version 10.10.3, homebrew-installed python 2.7.10 (python --version returns Python 2.7.10 which is the one installed by brew; which python points to /usr/local/bin/python). brew info graph-tool shows that all requirements of it are there (even the optional ones). GTK 2.24.28, GTK+3 3.16.4, PyGobject 2.28.6, GObject-introspection 2.28.6, Cairo 1.14.2, Py2Cairo 1.10.0, pango 1.36.8, XQuartz 2.7.7 etc are installed, dependencies of those are fine as well. gi 1.2 is installed (via pip), gi.repository is indeed not there. I am aware of this question, but I have PyGObjects installed.

I also read this question and the reply, but none of this solves my problem as far as I can judge.

I've spend two days looking for the solution, so any help is appreciated.

Community
  • 1
  • 1
olga.bio
  • 281
  • 3
  • 15

2 Answers2

2

It's seem to be a cairo dependency issue.

As you may see here, graph-tool package require a lot of depencies (numpy, gfortran, scipy, freetype, libpng, matplotlib, boost, cgal, graphviz, cairo, cairomm, py2cairo)

In your case you may probably solve the issue with a clean reinstall of "cairo".

Try those commands:

brew install cairo
brew install cairomm
brew install py2cairo

If "brew" ask you to run command or install other packages, do it !

(We assume here that "brew" is properly installed)

Best regards

A. STEFANI
  • 6,707
  • 1
  • 23
  • 48
  • Thanks for the reply. I had those installed, so I reinstalled all of the above. Still didn't solve the problem (same error message). – olga.bio Jul 17 '15 at 08:16
  • 1
    Dear Olga.bio, sorry for the late answer... I see (while browsing web) that your error message could be relative to gi library, so may you try to install or reinstall 'python-gi-cairo' and 'python-gi'. If the issue is still here after that could you please copy-paste the source code around line 1318 of the /usr/local/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py file. Thanks in advance. – A. STEFANI Aug 22 '15 at 19:35
1

I've faced the same issue (with a slight difference on the line number):

>>> from graph_tool.all import *
/usr/local/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py:1499: RuntimeWarning: Error importing Gtk module: No module named gi; GTK+ drawing will not work.
  warnings.warn(msg, RuntimeWarning)

I know it's a relatively old question but wanted to share how I did it. You said you tried reinstalling GObject, but that is what made it work here.

I followed the installing instructions

brew install pygobject3 --with-python@2 gtk+3

which said gtk+3 and pygobject3 were already installed. Then I ran:

brew reinstall gtk+3

and

brew upgrade pygobject3

which made the import work.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Fabrício
  • 91
  • 2
  • 7
  • Hey, thanks for the info! I can't test it as I am not using Mac anymore. If someone else can give feedback whether it works, I can accept it as the answer. – olga.bio Jul 05 '18 at 10:37
  • This gets 90% of it on Ubuntu 18.04. I followed `cairo` installation instructions, then: `pip install PyGObject --no-use-pep517` fixed it. – Alexander L. Hayes Dec 09 '20 at 02:40