Search code examples
pythoncompilationmakefilepygtk

How to compile pygtk from source for python2.6 on ubuntu 12.04


I have a application which is stuck at python2.6. I cannot port it to python2.7 due to specific and complicated extensions.

The probleme is that 12.04 removes pygtk for python2.6 as python2.7 becomes the default python version.

I need then to build pygtk for python2.6 from source. I have followed the readme but I am doing something wrong. (the doc is quite succinct)

The build looks ok, as I can import gtk if I am in the decompressed archive folder (I do a python -c 'import gtk'). But the make install doesn't work properly.

AFAICT, I have export'ed PYTHON & PYTHONPATH variables to the proper path.

PYTHONPATH=/usr/lib/python2.6/dist-packages
PYTHON=/usr/bin/python2.6

Any idea on what's wrong with this config ?


Solution

  • I don't know if I'm getting farther than you are, but here's what I'm doing so far. Maybe we can figure this out together.

    $ sudo su
    # pip install pygtk
    

    This generates a bunch of errors, including "To build PyGTK in a supported way, read the INSTALL file." After reading that and other things, I tried this:

    # cd build/pygtk
    # chmod 755 configure
    # PYTHON=/usr/bin/python2.6 ./configure --prefix=/usr
    

    This finds the right version of Python, but now can't find GLIB. Errors include, "This usually means GLIB is incorrectly installed." When I look in config.log I find this error, "fatal error: glib.h: No such file or directory". I found a help page that suggested you might get this error if you haven't installed a development version of GLIB.

    # apt-get install libglib2.0-dev
    # PYTHON=/usr/bin/python2.6 ./configure --prefix=/usr
    

    Progress! I now see a new error, "No package 'pygobject-2.0' found". That error appears in a forum post with a suggestion to install python-gobject-dev.

    # apt-get install python-gobject-dev
    # PYTHON=/usr/bin/python2.6 ./configure --prefix=/usr
    

    No errors, so I try running make and make install. The first one works, but the install fails with an error, "/bin/bash: line 16: ../py-compile: Permission denied". Permission denied is weird when running as root. After flailing for a while, I go back to the output of the configure script and see a message, "checking for PYCAIRO... no", followed by another, "not checking for gtk due to missing pycairo". A little guesswork leads me to install another module.

    # apt-get install python-cairo-dev
    # PYTHON=/usr/bin/python2.6 ./configure --prefix=/usr
    

    That solves the pycairo complaint, but there are a bunch more, including GTK.

    # apt-get install python-gtk2-dev
    # PYTHON=/usr/bin/python2.6 ./configure --prefix=/usr
    

    That solved most of the complaints, just LIBGLADE is missing.

    # apt-get install libglade2-dev
    # PYTHON=/usr/bin/python2.6 ./configure --prefix=/usr
    

    OK, all the modules will be built, but it says, "Numpy support: no".

    # make
    # make install
    

    This fails with the same error I saw earlier, "/bin/bash: line 16: ../py-compile: Permission denied".

    I'm going to leave it here for now and come back to it later.