I've had a lot of trouble trying to get Python working with Pygame on Ubuntu 12.04 so I've documented the process which finally got it up and running. Hopefully this will save someone else lots of work.

To get Python3 and Pygame working on Ubuntu 12.04, follow these steps:

  1. Open up the terminal and type the following code:

    sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev
  2. Then once all libraries are downloaded and installed, type:

    cd /usr/share/pyshared
    sudo svn co svn://seul.org/svn/pygame/trunk pygame
    cd pygame
    python3 setup.py build
    sudo python3 setup.py install

When I'd got these installed, I tried using IDLE as the default editor but found that I prefered editing files with nano as this is what I'm used to. The default syntax highlighting in nano wasn't particularly brilliant so I installed the nanorc syntax highlighting definitions from Git Hub which make the code so much easier to read. The steps to do this are as follows:

    git clone https://github.com/nanorc/nanorc.git
    cd nanorc
    make install
    echo 'include ~/.nano/syntax/ALL.nanorc' >> ~/.nanorc


comments powered by Disqus