4

I'm working in a program that is written in Gtk+ 3 and Python. A related question I asked about my program is here.

Now, that I advanced a bit more, I have the following imports:

import aplpy
import montage
import subprocess
from gi.repository import Gtk, GdkPixbuf

and when I run it I get this error:

$ ./makeRGB-frame.py 
Traceback (most recent call last):
  File "./makeRGB-frame.py", line 34, in <module>
    from gi.repository import Gtk, GdkPixbuf
  File "/usr/lib64/python2.7/site-packages/gi/__init__.py", line 27, in <module>
    from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

If I change the order of the imports:

from gi.repository import Gtk, GdkPixbuf
import aplpy
import montage
import subprocess

I also get an error:

$ ./makeRGB-frame.py 
/usr/lib64/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
  from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

The imported modules are: APLpy and python-montage.

Please help me to workaround those errors. Any help is appreciated!

Germán.

Community
  • 1
  • 1
skytux
  • 1,236
  • 2
  • 16
  • 19

1 Answers1

3

Some of your modules are using the static Gtk+ 2.0 bindings "PyGtk": http://www.pygtk.org/ Your are using dynamic Gtk+ 3.0 bindings "PyGObject": https://live.gnome.org/PyGObject

You cannot load both libraries at the same time, and if you do, you will have imports errors and segmentation faults.

My guest is that the responsible is APLpy module, you should check the source code a look for PyGtk imports, or ask the developer if PyGObject is supported.

Havok
  • 5,776
  • 1
  • 35
  • 44
  • Thanks for your answer @Havok. Now I'm sure that the responsible is APLpy, because commenting the others gives no errors. But I don't see any pygtk imported in APLpy. The output of the command `grep -i pygtk /usr/lib/python2.7/site-packages/aplpy/*.py` returns nothing. – skytux Mar 22 '13 at 12:47
  • skytux is right, there are no explicit uses of gtk in aplpy, but aplpy uses matplotlib, which can use gtk. @Havok, any idea if matplotlib can cause the clashes? – keflavich Apr 12 '13 at 00:18
  • 1
    This issue was solved changing the **matplotlib backend**, as explined [here](https://github.com/aplpy/aplpy/issues/103) – skytux Apr 12 '13 at 01:08