trouble installing pygame on ubuntu 16.04 LTS

To install PyGame for Python 3.x on Ubuntu 16.04 (default python3 is version 3.5.1) open the terminal and type:

sudo apt install python3-setuptools
sudo easy_install3 pip
python3 -m pip install --user pygame

The above commands also work on Ubuntu 18.04.

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

sudo apt install python3-pygame

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

To install PyGame for Python 2.x in Ubuntu 20.04 and earlier open the terminal and type:

 sudo apt install python-pygame