简体   繁体   中英

Installing PyGame onto Mountain Lion OS

Okay, so I've completely given up.

I've tried about a thousand different walkthroughs to solve my problem, on every website I can find, but I either get stuck and no one knows the answer, or they just don't work.

So has anyone got an answer to installing PyGame onto Mountain Lion that they know 100% works and they can walk me through it as if I'm 6 years old?

I just want to run PyGame and this is driving me insane.

Cheers.

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

如果您安装了MacPorts ,您可以运行sudo port install pyXX-game ,其中XX是您的macports python版本,从24到27和31到32.这样它将自动处理所有依赖项,理论上应该可以解决该框,假设您的系统默认设置为使用macports python。

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM