Getting Set Up with Python and Pygame
Over the years I've delivered various workshops introducing teachers and others to use Pygame to create games. Many recent workshops have included me using PygameZero instead of Pygame, but for this series of posts I think I'll just focus on vanilla Pygame.
Firstly you need an up-to-date install of Python 3. Newer versions allow you to just pip install pygame which definitely works on Linux, probably works on Windows (as long as you've ticked the box to add the Python Path to the Environment variables) and may work on Mac. The key seems to be to upgrade the version of pip that your Python is using.
Once you've ensured that you have a reasonably up-to-date Python (I've just upgraded top Python 3.7.3), we can upgrade pip by doing the following:
sudo -H python3,7 -m pip install --upgrade pip
This may or may not upgrade things depending upon what you've done previously.
If you haven't installed pygame previously then doing some version of the following should install it for you:
sudo -H python3,7 -m pip install pygame
If you've previously installed it and want to check that the newest version (1.9.5 is the most recent version at the time of writing) us installed then do the following:
sudo -H python3,7 -m pip install --upgrade pygame
To check that everything is working, run your new version of python:
python3.7
Then in the Python Shell which opens (you should be able to see the Python version here too), do:
>>> import pygame
Which should show you the following output for a new version of pygame (it didn't before Pygame 1.9.4 I think).
pygame 1.9.5
Hello from the pygame community. https://www.pygame.org/contribute.html
If you see all of this, with no errors then you should be good to go.
We'll leave this first part at that and continue by actually creating a window, in code in the second part of this guide.