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!


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

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!


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-02-16T05:00:00+00:00) How to install Pygame Zero on macOS. Retrieved from https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/

MLA
" » How to install Pygame Zero on macOS." flaviocopes.com | Sciencx - Tuesday February 16, 2021, https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/
HARVARD
flaviocopes.com | Sciencx Tuesday February 16, 2021 » How to install Pygame Zero on macOS., viewed ,<https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/>
VANCOUVER
flaviocopes.com | Sciencx - » How to install Pygame Zero on macOS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/
CHICAGO
" » How to install Pygame Zero on macOS." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/
IEEE
" » How to install Pygame Zero on macOS." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/. [Accessed: ]
rf:citation
» How to install Pygame Zero on macOS | flaviocopes.com | Sciencx | https://www.scien.cx/2021/02/16/how-to-install-pygame-zero-on-macos/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.