python3 is not supporting gtk module
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 Gtkand replace gtk by Gtk in your code
or
from gi.repository import Gtk as gtksee also : Python GTK+ 3 Tutorial : Getting Started
2Use the GObject introspection based Python3 bindings for Gtk and friends:
from gi.repository import Gtk, GObjectThat 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