How to download pygame in python3.3

Solution 1:

Here's a link to a solution for Ubuntu 12.04. Hope it helps. From the terminal:

  1. Change to your home directory.

    cd ~
    
  2. Get Pygame source code.

    sudo apt-get install mercurial
    hg clone https://bitbucket.org/pygame/pygame
    cd pygame
    
  3. 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
    
  4. Build and install Pygame.

    python3 setup.py build
    sudo python3 setup.py install
    

Solution 2:

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

Solution 3:

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/)

  1. Change to your home directory.

    cd ~
    
  2. Get Pygame source code.

    sudo apt-get install mercurial
    hg clone https://bitbucket.org/pygame/pygame
    cd pygame
    
  3. 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
    
  4. 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
    

Solution 4:

Ubuntu 19.04 and later

To install PyGame for Python 3.x on Ubuntu 19.04 and later open the terminal and type:

sudo apt install python3-pygame

Ubuntu 18.10

To install PyGame for Python 3.x on Ubuntu 18.10 open the terminal and type:

sudo nano /etc/apt/sources.list  

Add this line to sources.list.

deb http://archive.ubuntu.com/ubuntu/ cosmic-proposed universe 

Save sources.list with the keyboard combination Ctrl+O and press Enter and exit with Ctrl+X

Update the list of available software and install python3-pygame.

sudo apt update  
sudo apt install python3-pygame 

Ubuntu 14.04-18.04

sudo apt install python3-pip
python3 -m pip install pygame