Installing PyGame onto Mountain Lion OS

喜夏-厌秋 提交于 2019-12-03 15:35:20
BenDundee

Ok, I'm running OSX 10.8.3 (Python 2.7.3), and I got pygame (1.9.1) up and running in about 15 minutes.

Here's what I did. I brewed my Python a long time ago, so I forget the steps there. I seem to remember editing some symbolic links in \usr\local. At any rate, I'll assume you can use google as well as I can to figure out what to do here.

  1. download homebrew
  2. brew install python27 if you don't have it
  3. pip install numpy if you don't have it.
  4. brew install sdl
  5. brew install sdl_gfx sdl_image sdl_mixer sdl_ttf
  6. Download pygame v1.9.1 source for Unix architecture.
  7. cp ~/Downloads/pygame-1.9.1release.tar.gz /tmp/pygame-1.9.1.tar.gz` or wherever. Go to that directory.
  8. sudo tar -xvf pygame-1.9.1.tar.gz
  9. sudo python config.py should fail with a hint to edit Setup
  10. sudo emacs Setup, or your favorite text editor.
  11. Look for the entries for SDL, FONT, IMAGE and MIXER.
  12. Replace them with SDL = -I/usr/local/include/SDL -L/usr/local/lib -lSDL, FONT = -lSDL_ttf, IMAGE = -lSDL_image, and MIXER = -lSDL_mixer, respectively.
  13. cd src, emacs scale_mmx64.c. Look for all occurrences of movsxl with movslq. You should find two occurrences.
  14. cd .. and sudo python setup.py install

I only checked that I can load pygame from the prompt in Python, I didn't check anything else.

Refs:

http://jalada.co.uk/2011/06/17/installing-pygame-on-os-x-with-a-homebrew-python-2-7-install.html Error when Installing Pygame on Mountain Lion

If you have MacPorts installed, you can run sudo port install pyXX-game where XX is your macports python version from 24 to 27 and 31 to 32. This way it'll take care of all your dependencies automagically, and should theoretically work out of the box, assuming your system is set up to use macports python by default.

Here are my steps about how to install Pygame WITHOUT tweaking the config file + installing manually.

I'm running OSX 10.9.2 (Python 2.7.7), and I got pygame (1.9.2a0) up running just now.

Assume you already have homebrew, python and pip installed.

brew install libvorbis sdl sdl_image sdl_mixer sdl_ttf portmidi
brew install mercurial
# activate virtual env or use sudo:
pip install hg+http://bitbucket.org/pygame/pygame

Pygame Official Answers

tftdias

I have just faced this problem and, at the moment, my pygame installation seems to be ok.

I first tried the Homebrew to install python (2.7.5) and pygame. After install them through Homebrew I was able to import pygame module on python console. But, when I tried to run a pygame application with some jpg images the error "pygame.error: File is not a Windows BMP file" occurred. This error meas that only BMP images can be used in pygame applications (not reazonable), and it seems it can be fixed by installing a previous binary of pygame for Mac OS X 10.3, as mentioned here. Since I installed it from the available Homebrew packages, I was not able to choose any version. For this case the solution given by BenDundee may solve the problem since he installed pygame with python.

I decided to try Macports to solve my problem. You can consult the page http://astrofrog.github.io/macports-python/ to get more information about python installation through Macports. After install python, assuming you install version 2.7.5, which package is python27, you should install py27-game package to get pygame. This was the solution that really worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!