Skip to content

Instantly share code, notes, and snippets.

@connorshea
Last active June 15, 2022 23:54
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connorshea/f539c91f210e72077ca9 to your computer and use it in GitHub Desktop.
Save connorshea/f539c91f210e72077ca9 to your computer and use it in GitHub Desktop.
Installing Homebrew, Python, and Pygame on OS X
  1. Open the Terminal.
  2. Install Homebrew.
  1. Install Python 2.7 with brew install python
  • Optionally you can also install Python 3 with brew install python3
  • Installing either of these with install pip and pip3 respectively, a package manager for Python.
  1. Install prerequisites for pygame: brew install sdl sdl_image sdl_mixer sdl_ttf portmidi mercurial
  2. Install pygame using pip with pip install hg+http://bitbucket.org/pygame/pygame
  3. Install numpy and matplotlib using pip install numpy matplotlib

Then you can run Python scripts from the Terminal with python filename.py.

Why use Homebrew? So when you install things you can easily remove and reinstall them if they break, remove them if they're misbehaving or you no longer need them, or update your packages whenever updates come out (you can do that with brew update then brew upgrade). It also makes installing all kinds of languages and things super easy.

@BrendonYim
Copy link

I install all pygame follow all steps, but I got error like that

"python3.5/site-packages/pygame/__init__.py", line 105, in __getattr__
    raise NotImplementedError(MissingPygameModule)
NotImplementedError: movie module not available
(ImportError: No module named 'pygame.movie')"

@rafajaques
Copy link

AFAIK, pygame does not work well with python 3.

@cbscribe
Copy link

cbscribe commented May 1, 2017

AFAIK, pygame does not work well with python 3.

This is completely false. I have been using and teaching pygame with Python 3 for years now.

Also, these steps are all no longer necessary. This used to be the preferred method for OS X, but a few months ago Pygame distribution was updated and now all you need to do for all platforms is:

pip install pygame

@SeanFelipe
Copy link

Thanks for the tips!

@tenzin113
Copy link

Thank you!

@dhayden
Copy link

dhayden commented Jan 23, 2018

worked for me. I'm running MacOS with Sierra. Thanks!

Copy link

ghost commented Feb 24, 2018

It didn't work! Permission denied. I tried to install pygame but I failed.

Mac OS High Sierra

@bobbytoo2
Copy link

It worked for me: MacOS High Sierra, but it only installed for Python 2.7. How do I get it on Python 3.6.4? My Python3 is downloaded through Anaconda, if that's useful to know.

@oestrogen
Copy link

oestrogen commented Mar 15, 2018

@bobbytoo2 Run the same commands, but with pip3 instead of pip, to install libraries for Python 3.

@GrubBox
Copy link

GrubBox commented Apr 15, 2018

Can i install pygame without installing Xcode ? I am conscious that Xcode is a 6 GB file and i don’t programme in Xcode. I just need pygame but its failing to install without xcode —>

gcc -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Ddarwin -D_THREAD_SAFE -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/local/include/SDL -I/usr/local/include/SDL -I/usr/local/include -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/imageext.c -o build/temp.macosx-10.6-intel-3.6/src/imageext.o
xcrun: error: active developer path (“/Users/sandeepkrishnan/Desktop/Xcode-beta.app/Contents/Developer”) does not exist
Use sudo xcode-select –switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools, or use xcode-select –install to install the standalone command line developer tools.
See man xcode-select for more details.
error: command ‘gcc’ failed with exit status 1

@MisterFili
Copy link

Hey Gang,

i'm also on a journey to configure pygame

  • if you follow this link HERE you will see examples.

  • If you installed correctly you should be able to run this example code:
    python3 -m pygame.examples.aliens

@vian21
Copy link

vian21 commented Jul 31, 2018

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment