pythonpygtkpythonbrew

Cannot import pygtk in pythonbrew after manual install


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?


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 :

    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 :

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

    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 !