python3不支持gtk模块

我有支持python-2.7和python-3的Ubuntu 14.04。 我将我的python应用程序从python-2.7移植到python-3。 我有example.py文件,它导入下面的模块。 而我#!/usr/bin/python3作为python evn变量。

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

当我尝试使用python3运行时,我遇到了上述错误。

知道这里缺少什么吗?

尝试:

 from gi.repository import Gtk 

并在代码中用Gtk替换gtk

要么

 from gi.repository import Gtk as gtk 

另见: Python GTK + 3教程:入门

对Gtk和朋友使用基于GObject内省的Python3绑定:

 from gi.repository import Gtk, GObject 

这需要默认安​​装的python3-gi包。

自PyGTK以来,一些名称已发生变化。 Python GObject Introspection API Reference可以帮助您查找新名称(以及其他更改)。