Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

python3 is not supporting gtk module

Writer Sebastian Wright

I have Ubuntu 14.04 with python-2.7 and python-3 support. I am porting my python application from python-2.7 to python-3. I have example.py file which is importing below modules. and I #!/usr/bin/python3 as python evn variable.

import gtk, gobject, time, sys, os, subprocess, signal
**ImportError: No module named 'gtk'**

I am getting above error, when trying to run with python3.

Any idea what is missing here?

2 Answers

try:

from gi.repository import Gtk

and replace gtk by Gtk in your code

or

from gi.repository import Gtk as gtk

see also : Python GTK+ 3 Tutorial : Getting Started

2

Use the GObject introspection based Python3 bindings for Gtk and friends:

from gi.repository import Gtk, GObject

That needs the package python3-gi which is installed by default.

Some names have changed since PyGTK. The Python GObject Introspection API Reference should help you to find the new names (and other changes).

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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