Gtk error : matplotlib graphtool interaction

Hello,

It seems that maplotlib and graph_tool can't live in the same python file.
When the following code is run from an ide (spyder or ninja) an error is
produced:

import matplotlib.pyplot as plt
import graph_tool.all as gt
import numpy as np
x = np.arange(0,7,0.1)
y =np.sin(x)
plt.plot(x,y)

yield the error:

(test-graphtool-matplotlib.py:5555): Gtk-ERROR **: GTK+ 2.x symbols
detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

Matplotlib was build with ubuntu 14.04:
     >>> print matplotlib.__version__
     1.3.1
and graph_tool was installed from a deb.

When a similar code is run from an ipython notebook, there's no error!
test-matplotlib-graph_tool.ipynb
<http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4025617/test-matplotlib-graph_tool.ipynb&gt;

jean-patrick

This is because you are using a GTK+2 backend of matplotlib, and
graph-tool uses GTK+3, and these two cannot live together. You should
use a different backend for matplotlib, such as GTK3Agg, GTK3Cairo,
QtAgg, Qt4Agg, TkAgg, etc.

Best,
Tiago

I have rebuild matplotlib such Qt4 is used by default as backend:

import matplotlib
import skimage.io as io
import matplotlib.pyplot as plt
#import graph_tool.all as gt

print matplotlib.__version__
print matplotlib.get_backend()
image1 = io.imread("/home/jeanpat/QFISH/Bos Taurus/2/DAPI/1.TIF")
image2 = io.imread("/home/jeanpat/QFISH/Bos Taurus/2/CY3/1.TIF")

plt.subplot(121, xticks=[], yticks=[])
plt.imshow(image1, interpolation='nearest')

plt.subplot(122, xticks=[], yticks=[])
plt.imshow(image2, interpolation='nearest')
plt.show()

The console output is :

Running: /home/jeanpat/Developpements/iPythonNb/chromosome recognition/Shape
and Graph/test_morphograph.py (Thu Jul 3 19:48:35 2014)

1.3.1
Qt4Agg

Execution Successful!

So Qt4Agg is used. However if the graphtool is imported, the interruption is
still there:

(test_morphograph.py:4851): Gtk-ERROR **: GTK+ 2.x symbols detected. Using
GTK+ 2.x and GTK+ 3 in the same process is not supported
Error during execution, QProcess error: 1

Execution Interrupted

The code was run from ninja-ide

I have rebuild matplotlib such Qt4 is used by default as backend:

You didn't have to rebuild it, just modify the matplotlibrc
configuration file.

[...]

So Qt4Agg is used. However if the graphtool is imported, the interruption is
still there:

(test_morphograph.py:4851): Gtk-ERROR **: GTK+ 2.x symbols detected. Using
GTK+ 2.x and GTK+ 3 in the same process is not supported
Error during execution, QProcess error: 1

In some distributions, the default theme used by Qt is QGtkStyle, which
uses GTK itself to draw the widgets, so that KDE programs blend in
seamlessly in GNOME. The problem is that this pulls in GTK+2 symbols,
and causes this conflict. You can verify/change this by running
qtconfig, and selecting for "GUI Style" something different than GTK+.

Best,
Tiago

This is it ! (The distro is lubuntu 14.04. )

Thank you

jean-pat