Why can't I import "pygtk" with Python 3.2 from PyDev?

I have installed Eclipse + PyDev + Python 3.2. Now I have two Python interpreters in PyDev: Python 2.7 and Python 3.2. If I try to execute command import pygtk with 2.7 interpreter it works fine, but with Python 3.2 it raises ImportError: No module named pygtk.

How can I get PyGTK to work with Python 3.2?

2 Answers

PyGTK has been deprecated in favor of PyGI+GTK. Because of that, a version of PyGTK for Python 3 was never written.

To use PyGI+GTK in Python 3, you need to install the python3-gobject package and do

from gi.repository import Gtk

For a quick introduction on porting PyGTK code to PyGI+GTK, see here:

For a full tutorial, see here:

3

One small addition: python3-gobject was renamed python3-gi in Precise. You can still install via the old name, but if you don't need to support anything older than Precise, use python3-gi in your debian/control.

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

You Might Also Like