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 220.127.116.11.
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-18.104.22.168.tar.bz2 | tar xvf - $ cd wxPython-src-22.214.171.124 $ 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-126.96.36.199) 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):
That’s it. Make sure “import wx” works under python2.6. If not, well…
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.