Installing Pygame for Python 3.1.2 in Ubuntu

PyGame on Python 3 remains experimental, but these steps worked for me on Ubuntu 11.10:

sudo apt-get install mercurial python3-dev libjpeg-dev libpng12-dev libportmidi-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev libx11-dev ttf-freefont libavformat-dev libswscale-dev
hg clone -u 01b2cb16dc17 https://bitbucket.org/pygame/pygame
cd pygame
python3 config.py
2to3 setup.py -w
python3 setup.py build
sudo python3 setup.py install

(You may remove the -u 01b2cb16dc17 to try the latest version; 01b2cb16dc17 worked for me.)


I hate to re-open an old post, but I had the hardest time installing pygame with a version of python that was not Ubuntu's default build. So I created this tutorial/ how to:

Install python3.1 and pygame1.9.1 in Ubuntu

I hopes this helps the next unfortunate soul to try this.