RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
Question: I'm using PyGTK for Python 2.7 in Ubuntu 14.04, but I get the following
message:

    
    
    RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
    

What could be the reason ?


Answer: When does it trigger? Are you trying to run some script or just use PyGTK
interactively?

Most likely, your input hook is grabbed by another interactive loop, e.g.:

    
    
    >>> import Tkinter
    >>> root = Tkinter.Tk() # input hook is grabbed by Tkinter for immediate result evaluation
    >>> import gtk          # gtk tries to grab the hook, but fails
    /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:127: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
    

The _immediate result evaluation_ means that an expression results are
evaluated immediately (e.g. window is displayed) before entering the main
loop.

Have in mind, that this is a warning, not an error, but if it bothers you, you
can import gtk module as early as you can (or, well, reasonably early) and
release the input hook:

    
    
    import gtk
    gtk.set_interactive(False)
    import Tkinter
    root = Tkinter.Tk()
    # no warning here
    

