Question

Since it is impossible to install pygtk via pip I tried to install it manually.

I downloaded the source tar from pypi and ran

./configure --prefix=/home/user/.pythonbrew/pythons/Python-2.7.2
make
make install

It installed alright, e.g. pygtk-demo is in my path. However whenever I try to import pygtk I get the following error:

>>> import pygtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pygtk

I seem to miss something or made an error. What do I have to do to be able to use pygtk?

Was it helpful?

Solution

I do not use pip or pythonbrew, but here is my experience, hope it can help and maybe put you on the good path !

The best option is to use the repository. Under ubuntu, this goes with synaptic or apt-get.

When manually must be choosen, remember the pygtk is just a bridge to the gtk package, and this one must be installed first. Usually, it happens this way :

  • download gtk.zip, and unzip in a folder, say "gtk".
  • add that folder "gtk" to your path

that's it, gtk is installed. now you can fasten it up with the blas/lapack math libs. You need a fortran compiler to do this.

Then after, you may think of pygtk.

But this one needs other py-things in order to run correctly, and they must also been installed first :

  • pyGobject : lets you communicate with gtk objects
  • pyCairo : handles the pretty fonts in the graphs, tables, ...

For all those py-something packages, the to-do way is always :

  • download, then unzip in a temporary folder
  • go to that temporary folder
  • python setyp.py make
  • python setup.py install

I did this several times on ubuntu 8, 9, 10 and 11, with success, when versions of all the packages where compatible between each other, which was not always easy....

If you can find "bundles" with all in it for your platform, give them your preference.

Then, the first thing to do is to test in python :

import gtk
import pygtk

Good luck !

OTHER TIPS

You need to set the environment variable PYTHONPATH. Thus, Python will know where to look at.

Try:

$ export PYTHONPATH=/home/user/.pythonbrew/pythons/Python-2.7.2/lib/python/...

where 'lib/python/...' is the real path to the module pygtk.

You might want to add that line in your ~/.profile, ~/.bashrc or ~/.bash_profile (or the one that applies to the shell you use).

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