Macos – Installing pygame on Snow Leopard’s system Python 2.6

macososx-snow-leopardpython

Snow leopard has python 2.6 included now, and I want to install pygame on it, but it says its for Python from python.org, not system python. I tried using setup.py from source, but it didn't work. Is there some way I can install pygame on the system Python 2.6? I don't want to have two installations of python of the same version. Thanks.

Hmm… I found this under the Mac OS X Binaries heading in install.html in the pygame source download folder:

If you want to use the Apple system
python, you will need to compile from
source at this time – since most
people prefer to leave the system
python alone, and use the python
downloaded from python.org. See
http://pygame.org/wiki/MacCompile for
current instructions for compiling
from source on Mac OSX.

Best Answer

  1. Download http://www.libsdl.org/tmp/SDL-1.2.tar.gz
  2. Double-click Xcode.tar.gz, it un-tars as Xcode
  3. Navigate to Xcode/SDL, double-click SDL.xcodeproj
  4. Project menu->Edit Project Settings
  5. Choose "Build" tab, then make sure Deployment_for_official.. is selected in the "configuration" dropdown
  6. Scroll all the way to the bottom, change SDKROOT_i386 and SDKROOT_ppc to /Developer/SDKs/MacOSX10.6.sdk and close the project settings
  7. Make sure that "Use Base SDK", Deployment_for_official_releases..., "Framework", "Standard DMG" and "x86_64" are selected in the Overview menu.
  8. Click Build (you will get warning, but it should compile with no errors)
  9. Copy the "SDL.framework" folder from "Xcode/build/" to "/Library/Frameworks"
  10. Download the pygame source and extract it
  11. Run ./configure.py
  12. Run the following shell commands:

    export CC='/usr/bin/gcc-4.0' CFLAGS='-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64'

    export LDFLAGS='-arch x86_64'

    export ARCHFLAGS='-arch x86_64'

    python setup.py build

    python setup.py install

The last command may need you to use sudo instead.