Sean McManus’s Mission Python – Code A Space Adventure! was finally released last week, I ordered my copy from my favourite publisher No Starch Press and was good to go.
The intro walks you through the process of installing Python and Pygame Zero for both Windows PC and Raspberry Pi.
Even though “Installing the Software on Other Machines” is included it doesn’t really cover macOS and since I had some fun setting it up on my MacBook, I decided to do a post to get you quickly started on your “Space Adventure”
Installing Python 3
macOS (10.14) comes standard with Python 2.7.10 installed but since the book recommends 3.6.6, You can download it from here
Once you have downloaded the package (macOS 64-bit installer) and installed it following the prompts, you can do a quick check by doing the below –
Open Terminal – Spotlight Search (cmd+spacebar), type “terminal” and press Enter.
Version Check – In the Terminal window type “python3 —version” and press Enter.
You should see “Python 3.6.6”
Verify the installation directory – In the Terminal window type “which python3” and press Enter.
You should see “/Library/Frameworks/Python.framework/Versions/3.6/bin/python3”
Python 3 is now installed.
Download the get-pip.py script from here
In terminal you would need to change to the directory where you have downloaded the script, in my case its Downloads, type “cd Downloads” and press Enter.
Once in the Downloads directory type “python3 get-pip.py” and press Enter.
Once the script has run, to verify type “which pip3” and press Enter.
You should see “/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3”
pip 3 is now installed.
Installing Pygame Zero
In terminal type “pip3 install pgzero” and press Enter.
After the installation has run you should see “Successfully installed…”
Pygame Zero Installed…
Now that we have setup Python 3 and Pygame Zero we can play the game as suggested in the book.
Downloading and Running the Game
In your web browser download the game files from here
Once the .zip file has downloaded I would recommend renaming it to “escape”
Double tap “escape.zip” file to unzip the file and you should now see an escape folder.
In terminal you should already be in the “Downloads” directory you would just need to switch to the “escape” directory by typing “cd escape” and press Enter.
And when you type “ls” in the escape directory you should the below directories and files listed –
If you have followed the above steps and have not hit any errors to play the game type “pgzrun escape.py” and press Enter.
Enjoy the Adventure…