I have a Python application that ran without problem on 12.10, but on upgrading to 13.04 the application fails with the following error :

except gi._glib.GError, e:

AttributeError: 'module' object has no attribute 'GError'

Is there a change in the Python 2 Gtk libraries associated with 13.04 ?

  • Did you write the application? If not, where does it come from? – Jennifer Wilson Apr 27 '13 at 9:40

Functions, methods, attributes, etc with an underscore are used as internal methods in Python. These can change or deleted without warning, so it's better to never use these outside that package.

Try the following:

>>> from gi.repository import GObject, GLib
>>> GObject.GError
<class 'gi._glib.GError'>
>>> GLib.GError
<class 'gi._glib.GError'>

This also works on Ubuntu 12.10 and possibly earlier.

| improve this answer | |

This import error occurs on Ubuntu 14.04, but not on Ubuntu 12.04. Basically due to the transition from Python 2.x -> Python 3. Many modules were renamed or merged. Python 3 is NOT backward compatible with Python 2.x. So add this to the list of the gotchas.

ImportError: No module named 'gi._glib'

debian.org bugreport #705387

from gi._glib import GError


from gi.repository.GLib import GError
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.