How to install Pygame Zero on macOS
A few months ago I bought a book from Raspberry Pi Press called Code the Classics. It’s an awesome book that talks about some classic games, including Sensible Soccer and Centipede, and then proceeds to creating a clone of those games with Python. It’s a total of 5 games.
That’s a very nice book, you can download it for free at the link I provided above and you can find the code of the games built in the book on GitHub at https://github.com/Wireframe-Magazine/Code-the-Classics.
The book does not actually explain how to build those games, unfortunately. It just lists the source code.
Anyway, it’s a great way to start your Python game development adventure.
I finally found some time to dive into, and the first step was to install Pygame Zero, a library to create games on top of Pygame.
It’s not hard, in theory, to install it. It is distributed through pip, using
pip install pgzero
But I had troubles with my Mac. It failed during the installation withat
fatal error: 'SDL.h' file not found
#include "SDL.h"
^~~~~~~
1 error generated.
I checked what could be the problem, and I found a possible version requirement mismatch, maybe it’s a recent problem due to new releases of the libraries, but I had to install the latest version directly from GitHub, using:
pip install git+https://github.com/lordmauve/pgzero@master
Then it worked fine!
download all my books for free
- javascript handbook
- typescript handbook
- css handbook
- node.js handbook
- astro handbook
- html handbook
- next.js pages router handbook
- alpine.js handbook
- htmx handbook
- react handbook
- sql handbook
- git cheat sheet
- laravel handbook
- express handbook
- swift handbook
- go handbook
- php handbook
- python handbook
- cli handbook
- c handbook
subscribe to my newsletter to get them
Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing [email protected]. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.