Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Usually at work I lock my screen when I leave, log off once a week, and rarely reboot. All my packages are up-to-date.

Yesterday I rebooted, and this morning I can't launch my Python3/Gtk3 apps :

JeanCoiron@myhostname:/opt/myapps/dev$ ./ 
Traceback (most recent call last):
  File "./", line 4, in <module>
    from gi.repository import Gtk
  File "/usr/lib/python3/dist-packages/gi/", line 76, in load_module
  File "/usr/lib/python3/dist-packages/gi/", line 224, in _load
    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
  File "/usr/lib/python3/dist-packages/gi/overrides/", line 1533, in <module>
    raise RuntimeError("Gtk couldn't be initialized")
RuntimeError: Gtk couldn't be initialized

Code of this example app :

# Filename:

from gi.repository import Gtk
from gi.repository import Gdk

class MyWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="My window")

        self.mainGrid = Gtk.Grid()

        self.lbl = Gtk.Label("Hello World")

mainWin = MyWindow()
mainWin.connect("delete-event", Gtk.main_quit)


If I launch it from Geany it works, not from a standard terminal. Same for all my python3/gtk3 apps. From a Geany terminal echo $PATH is exactly the same as from a standard terminal. Curently DISPLAY=':0', I tried with no DISPLAY var and with DISPLAY='localhost:0'

Any idea where I should search ?


This is a Gtk issue only : I can launch Gtk apps like gedit from Unity launcher but not from a terminal.

JeanCoiron@myhostname:/opt/myapps/dev$ gedit /usr/lib/python3/dist-packages/gi/overrides/
Cannot open display: 
Run 'gedit --help' to see a full list of available command line options.
JeanCoiron@myhostname:/opt/myapps/dev$ echo $DISPLAY
share|improve this question
Try to run this script with python 2 explicitly to see if problems persists. Also checking what line that RuntimeError throws gives some more insight. Apparently it's Gtk.init_check() which fails, so Googling that might give some more useful results. – Timo Mar 28 '13 at 10:33
The error is exactly the same using python2 (python2 ./ – Jean Coiron Mar 28 '13 at 11:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.