Wednesday, May 18, 2016

Pygame for Python 3.x


As I continue working on MeRML (Medical Record Management for Linux), I have come to a point where I needed to do some things that required the libraries provided by Pygame. Doing the default installs using 'apt' from the Kubuntu 16.04 repositories I discovered that Pygame gets installed for use with Python 2.7 while Tkinter gets installed for Python 3.x. This doesn't "actually" work for me since my development is being done in 3.x so what to do?

A bit of Googling through a variety of forums and Pygame is in for Python 3.x. Now, I can utilize Ktinker as well as the Pygame libraries. This is what I had to do for those looking to accomplish the same results on Ubuntu and derivitive systems:

1. Install Mercurial
'apt install mercurial'

2. Create Directory
'mkdir .pygame'

3. Move to Directory
'cd .pygame'

4. Clone Libraries
'hg clone https://bitbucket.org/pygame/pygame'

5. Install Dependencies
'sudo apt install python-dev python3-dev python-numpy libav-tools libsdl-image1.2-dev
libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libsdl1.2-dev
libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev libfreetype6-dev
subversion ffmpeg'

6. Build Pygame
'python3 setup.py build'

7. Install Pygame into Python3.x
'sudo python3 setup.py install'

Pygame should now work with Python3.x

Either 'scrape' these instructions using something like eLinks -dump or copy and paste to your editor so they are saved for later. It's never fun to go back and have to dig up instructions multiple times over as it may be a while before the repo's are set up to install Pygame into Python3.x the easy 'apt' way.