How to download pygame in python3.3
Here's a link to a solution for Ubuntu 12.04. Hope it helps. From the terminal:
Change to your home directory.
cd ~
Get Pygame source code.
sudo apt-get install mercurial hg clone https://bitbucket.org/pygame/pygame cd pygame
Install dependencies.
sudo apt-get install python3-dev python3-numpy libsdl-dev libsdl-image1.2-dev \ libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libportmidi-dev \ libavformat-dev libswscale-dev libjpeg-dev libfreetype6-dev
Build and install Pygame.
python3 setup.py build sudo python3 setup.py install
Unfortunately you need to recompile it. And unfortunately the last stable version (1.9.1) doesn't support python 3...
So you need to download the last source code from the trunk, hopping it's not broken at this moment:
sudo apt-get install mercurial
hg clone https://bitbucket.org/pygame/pygame
You also need to download the build dependency:
sudo apt-get build-dep pygame
sudo apt-get install python3-dev
sudo apt-get install python3-numpy
This will install dependency used by the version of pygame available on your package depot. Newer version maybe need other dependency! We also need to specify python3-dev and python3-numpy because, well, build-dep will install python2 version of this packages...
You can now run:
cd pygame
python3 config.py
If some dependency are missing config.py will list them and ask if you want to continue if this dependency are not mandatory. You can install them if you want/can or simply ignore it and probably loss some functionality.
Now it's time to build and install:
python3 setup.py build
sudo python3 setup.py install
I attempted to add this to the accepted answer, but it was rejected, so I'm posting it as a separate answer.
In more recent versions of Ubuntu and Ubuntu derivatives (ex: Xubuntu 16.04 LTS), the accepted answer is missing one important dependency before calling the build command, namely: python3-setuptools
. Therefore, I'm posting this answer with that dependency added.
I've successfully completed the steps below in Xubuntu 16.04 LTS in order to install pygame
into Python 3.5.2.
(Note: to install pygame into Python 2 simply use sudo apt-get install python-pygame
).
To install it into Python 3.x, do the following:
(Original source: http://heritagerobotics.wordpress.com/2012/11/20/compiling-pygame-for-python-3-2-in-xubuntu/)
Change to your home directory.
cd ~
Get Pygame source code.
sudo apt-get install mercurial hg clone https://bitbucket.org/pygame/pygame cd pygame
Install dependencies.
sudo apt-get install python3-dev python3-numpy libsdl-dev libsdl-image1.2-dev \ libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libportmidi-dev \ libavformat-dev libswscale-dev libjpeg-dev libfreetype6-dev python3-setuptools
Build and install Pygame.
python3 setup.py build #build by passing the "build" command as an argument to the setup.py module sudo python3 setup.py install #install by passing the "install" command as an argument to the setup.py module