Pygame Zero programs

The example programs now all in one book

Distributing your Pygame Zero games

You can distribute your games to people who don’t have Python or Mu installed. You can put them on a USB stick, or a website for people to download, or even on itch.io for people to buy.

  1. Install the full version of python from here

  2. Edit your game source code (using Mu). We will assume your source is in a file NAME_OF_GAME.py. At the top of the file add the line:

    import pgzrun

    At the bottom of the file add the line:

    pgzrun.go()

    Save it.

  3. Open a command prompt (Click start menu and type cmd.exe)

  4. Enter your mu_code folder. At the prompt type:

    cd mu_code

  5. Install pyinstaller and pgzero. At the command prompt type:

    pip install pgzero pyinstaller

  6. Copy the pgzero folder into your mu_code folder. You should find the pgzero folder at:

    C:\Users\YOURNAME\AppData\Local\Programs\Python\Python37\Lib\site-packages\pgzero

    You should find your mu_code folder at:

    C:\Users\YOURNAME\mu_code

  7. Create the executable. At the command prompt type:

    pyinstaller NAME_OF_GAME.py --distpath . --add-path "pgzero;pgzero" --onefile --noconfirm --nowindow

    This will generate a program called NAME_OF_GAME.exe. You can double click this program to play your game.

  8. To distribute your game you need to copy the entire mu_code folder. You could put it inside a zip file, and then put that on a website.