If you need to develop Python 3 application in Pygame on Mac, you should have noticed that there is no official installer of Pygame for Python 3 on Mac. However, you can still install Pygame for Python 3, just via Pygame repository.
If you do not want bother the details, you may use my modified Pygame formula for Homebrew to install Pygame. Remember to install HEAD version or Python 3 will not be supported.
If you want to install Pygame with
pip, I still suggest Homebrew to install dependencies for Pygame. To install Homebrew, follow Homebrew official site or my article. After installation of Homebrew, you can install other software.
Install Mercurial, a version control software. We will use Mercurial to download Pygame source code later.
Install Python 3, since there is no Python 3 on Mac. Installing Python 3 with Homebrew is suggested because Homebrewed Python 3 modules are placed in the subdirectories of /usr/local and root priviledge is not needed.
Install some dependencies including jpeg, libpng, portmidi, smpeg and numpy. smpeg is in “head-only”, meaning that there is no stable version tarballs. You have to
brew tap homebrew/headonly before installing smpeg. Besides, remember to add Python 3 support for numpy.
Install SDL (Simple DirectMedia Layer), a cross-platform library for multimedia and game. You need to install sdl, sdl_image, sdl_mixer and sdl_ttf.
Install Pygame with
pip3. Be not confused with
pip, which is for Python 2.
Finally, test Pygame with a small code snippet: