Question

I am configuring pygtk in my centos 5.4 machine. But I am facing few issues.

I want pygtk to be configured to Python 2.7(The default python version is Python 2.4 in centos 5)

So I installed Python 2.7 with different --prefix to my local space and then installed pygobject2.28 and then pygtk2.24 with the --prefix="where python 2.7 installed".

But when I run python2.7 interpreter I am able to import pygtk but, when I try to import gtk it says "no module named gtk."

I have configured PYTHONPATH and PYTHON environment variables to python2.7/lib/site-packages and python2.7 respectively.

My questions:

  1. if pygtk is a wrapper for gtk then why am not able to import gtk, when I am able to import pygtk.
  2. Where does python(or pygtk) pick the gtk from?
  3. And how can I solve the above problem!?

I tried google and other stack overflow questions. But none of them answered the above quesions.

Was it helpful?

Solution

I wasn't checking the ./configure output properly. The problem was, I was trying to install gtk and pygtk without installing cairo and pango. So pygtk skipped building gtk packages because it did not find any cairo package. This was mentioned in the ./ configure script but I had not checked that.

Summarizing:

To configure pygtk to python need to folow these steps

install sqlite-devel #If sqlite needed
install python(2.7)
install gtk(2.24.0) -> requires glib(2.27.3), atk(1.29.2), cairo(1.8.10), pango(1.22.4), gdk-pixbuf(2.21.3)
install pygtk(2.24.0) -> requires pygobject-2.28.3, pycairo(1.8.10)

All the above packages must be compiled to the same prefix, and need to set the PYTHON and PATHONPATH environment variables. The versions of packages also play major role. Added version in parenthesis that worked for me.

There are many dependencies while installing some of the packages so I had to install following packages using yum: libxext, librender, gettext, zlib, libgtk2-devel

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top