Installing Pygame for Python 3 on OS X
Here is a quick tutorial on how to get Pygame up and running with Python 3 on a Mac with OS X 10.6.
The Pygame download site presently has packages for Python 2.4, 2.5, 2.6 and 2.7 for OS X, but none for Python 3 (3.2 to be precise). This is odd, as everyone is doing Python 3 development these days, don't you think? And there even is an installer for Python 3 on MS Windows. So, let's change that and get Pygame working with Python 3 under OS X.
Make sure the thing in front of you is an Apple computer with an OS X operation system. I my case it was a MacBook Pro with OS X 10.6.6 "Snow Leopard".
You will need XCode, the Apple developer toolset. For OS X 10.6 "Snow Leopard", you will find it on the installation DVD under "Optional Packages" or similar. For OS X 10.7 "Lion" you can download XCode for free in Apple's App Store.
To learn about your computer's operating system version, click the apple symbol in the top left and select the first menu item "About This Mac".
Get A Package Manager
Next, get a decent package manager to be able to conveniently install dependencies. I used Homebrew, and so should you. In the Finder, go to Applications -> Utilities and start the Terminal. To install Homebrew, type
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
and hit Return.
Install Python 3
Homebrew has a recipe for Python 3, which we are going to use. Type
brew install python3
and hit Return. Once that is done, verify the Python version by typing
The following is taken from a Pygame Issue Tracker thread.
First install the Mercurial version control system:
brew install mercurial
Then do the same for the git version control system, which is needed by a dependency package:
brew install git
Now install all the dependencies of Pygame:
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
Almost there! To install Pygame now, we will use pip. Go and get it by running:
And now, finally:
/usr/local/share/python3/pip install hg+http://bitbucket.org/pygame/pygame
After this is done, verify that it is working:
python3 >>> import pygame >>> pygame.init() (6, 0) >>> pygame.display.set_mode((800, 600)) <Surface(800x600x32 SW)> >>> raise SystemExit
That's it! Now you have Pygame for Python 3 installed and working and can start hacking.