8

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.

3
  • 2
    I've never been able to install it on Leopard so I'm interested in the answer to this question. Sep 18, 2009 at 23:00
  • Do you have the dev tools installed? I've never had luck installed 3rd party libs into the /Library or /System/Library without the dev tools installed beforehand.
    – sal
    Sep 23, 2009 at 14:27
  • I have the dev tools and succed in installing other libraries, but I never was able to install pygame. Sep 24, 2009 at 0:03

6 Answers 6

6
  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.

1
3

Due to a broken "reputation" system I cannot comment on Scott Lyon's post, but I will add that it worked save for one modification: For the last command, I had to specify the installation directory for the Python module like so:

sudo python setup.py install --install-lib /Library/Python/2.6/site-packages/

2

Have you tried installing it using easy_install or pip?

I haven't tried it yet, but I know I was about to install the needed libraries (SDL_game, etc) via port, then install pygame with

sudo easy_install pygame
1
  • This works for me-- the Pygame binary won't let you, and compiling from source gave me an error about gcc not found. You may have to hunt down some dependencies to get all the features working though-- such as the SDL framework. Pay attention to the Pygame log when it installs, then when you hunt down the dependencies, reinstall from easy_install
    – Jeff
    Sep 27, 2011 at 16:08
1

Pretty important to get the latest SDL_image.framework if you want actual PNG/JPEG support:

http://www.libsdl.org/projects/SDL_image/

Otherwise it will only load Windows BMP files as you will see this during the build:

/Library/Frameworks//SDL_image.framework/SDL_image, missing required architecture x86_64 in file

0

I'd prefer to comment on Scott Lyon's excellent answer, but looks like I'm stuck creating a new answer.

Scott's steps worked great for me, but I also had to do the same thing for SDL_mixer, SDL_image, and SDL_ttf. All of them worked great, except for SDL_ttf; I had to download and use the prerelease version of 2.0.10 linked from here:

http://forums.libsdl.org/viewtopic.php?t=4984

Also note that Scott's step #7 is referring to the Project menu; specifically the Project=>Set Active Target, Project=>Set Active Architecture, etc. menu items and his step #11 should actually be python config.py

0

Following up on One Crayon's post: After building SDL (according to Scott's instructions) I simply installed the binary distributions for SDL_mixer and friends (from subdirs of http://www.libsdl.org/tmp). That seems to work fine, so far.

Not the answer you're looking for? Browse other questions tagged or ask your own question.