Installing wxPython 2.8 on Debian Lenny

Actually Debian has the python-wxgtk2.8 package which you can simply apt-get if you wish to have it installed as part of Python 2.5 which is the stable version for Lenny.  I’m adding wxPython 2.8 to Python 2.6, which I installed from source.

I mostly followed what the official wxPython installation guide says.  It was not a smooth installation for me, so this is my own installation note.  The version is 2.8.10.1.

First, download the tarball for wxPython from the official repository.  Here I assume the archive is downloaded to /usr/local/src/wx.

Some libraries need to be installed since wxWidgets will be built against them:

$ sudo apt-get install libgtk2.0-dev libglu1-mesa-dev

You need to first build wxWidgets, and then build extension module for wxPython.  Anyways, decompress and untar, and create a working directory for building wxWidgets:

$ bunzip2 -c wxPython-src-2.8.10.1.tar.bz2 | tar xvf -
$ cd wxPython-src-2.8.10.1
$ mkdir bld
$ cd bld

In the bld directory, create a file named .configure with the following content:

#!/bin/sh
../configure \
 --prefix=/usr/local/lib/wx/2.8 \
 --with-gtk \
 --with-gnomeprint \
 --with-opengl \
 --with-libjpeg=builtin \
 --with-libpng=builtin \
 --with-libtiff=builtin \
 --with-zlib=builtin \
 --enable-optimize \
 --enable-geometry \
 --enable-graphics_ctx \
 --enable-sound --with-sdl \
 --enable-mediactrl \
 --enable-display \
 --enable-unicode \
 --enable-rpath=/usr/local/lib/wx/2.8/lib

Here I am assuming the newly build wxWidgets library will be installed under /usr/local/lib/wx/2.8.  You may change the installation location, of course.  For details on what these switches will do, refer to the official installation guide for wxPython.

Create a file named .make with the following content:

#!/bin/sh
make $* && make -C contrib/src/gizmos $* && make -C contrib/src/stc $*

Give both the files an executable permision, and do the usual thing:

$ chmod +x .configure
$ chmod +x .make
$ ./.configure

...

$ ./.make
$ sudo ./.make install

If this process ends without errors, you are ready to install wxPython. Before you run setup.py, however, you need to patch a source file.  Download this diff file to the top installation directory (i.e., wxPython-src-2.8.10.1) and run the patch:

$ cd ..
$ wget http://devide.googlecode.com/svn/trunk/johannes/patches/wxpython28101_gdiwrap.diff
$ patch -p0 < wxpython28101_gdiwrap.diff

After the patch is applied correctly, move to wxPython directory:

$ cd wxPython

Now, in config.py, you need to find the line that starts with WX_CONFIG and set the variable to the path to wx-config script, /usr/local/lib/wx/2.8/bin/wx-config in our case:

WX_CONFIG = '/usr/local/lib/wx/2.8/bin/wx-config'

Then finally install the wxPython package:

$ python2.6 setup.py build_ext --inplace
$ sudo python2.6 setup.py install

Here I’m running setup.py as a Python 2.6 script since I want to install wx into the site-packages directory for Python 2.6.

$ python2.6
$ import wx

If this gives no ImportError, it is a success.  If you receive an error, check the permission of wx.pth undersite-packages; the file must be world readable (i.e., 644).

To avoid ImportError upon importing wx in Python, you need to add the following line in ~/.bashrc (or ~/.bash_profile):

export LD_LIBRARY_PATH=/usr/local/lib/wx/2.8/lib:${LD_LIBRARY_PATH}

That’s it.  Make sure “import wx” works under python2.6.  If not, well…

TODO

I want to have wx loaded without specifying LD_LIBRARY_PATH.  Using the –enable-rpath option is supposed to do this, but it apparently doesn’t for me.

This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

6 Responses to Installing wxPython 2.8 on Debian Lenny

  1. Pingback: Installing wxPython 2.8 on Debian Lenny | Debian-News.net - Your one stop for news about Debian

  2. Pingback: Installing NumPy, SciPy, & Matplotlib on Debian Lenny (AMD64) with Python 2.6 « Biboroku

  3. Pingback: Installing NumPy, SciPy, & Matplotlib on Debian Lenny (AMD64) with Python 2.6 | Biboroku

  4. Vladimir says:

    Hi, thanks a lot for this guide, it’s very helpful.
    Just wanted to note that:

    –enable-graphic_ctx

    should be spelled as

    –enable-graphics_ctx

  5. Liam Gretton says:

    The LD_LIBRARY_PATH issue can be fixed by hacking wx-config (pending a proper fix from the author).

    Add the following line near the start:

    _rpath="-Wl,-R/usr/local/lib/wx/2.8/lib"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>