I am trying to install pygame for Python3 using Homebrew. (I have both Python 2 and Python 3 on my machine.)
I used this Reddit page, which says:
brew tap Homebrew/python
brew update
brew install pygame
This works perfect and installs pygame
successfully on my Python 2.7. However, Python 3 still does not have pygame
.
I also found that I can do it using pip3
. However, I am looking for a way to install pygame for Python 3 using Homebrew.
Adding --with-python3
is the key here. You can install via brew install --with-python3
.
In general brew info <package-name>
will give you additional information. In this case brew info pygame
prints:
homebrew/python/pygame: stable 1.9.2a0, HEAD
http://pygame.org
Not installed
From: https://github.com/Homebrew/homebrew-python/blob/master/pygame.rb
==> Dependencies
Required: sdl ✔, sdl_image ✔, sdl_mixer ✔, sdl_ttf ✘, smpeg ✘, jpeg ✔, libpng ✔, portmidi ✘, homebrew/python/numpy ✘, freetype ✔
==> Options
--with-python3
Build with python3 support
--without-python
Build without python2 support
--HEAD
Install HEAD version
Homebrew might be the tool you need to get this done. But first;
- Do you have homebrew installed?
To check, in your terminal, type in brew. A list of commands should follow. If not install homebrew, here https://gorails.com/setup/osx/10.11-el-capitan, and follow the homebrew instructions section
- Once homebrew is setup, run 'brew update'
- Then run 'brew install pygame'. It might prompt you install 'homebrew/python/pygame' instead, copy that command and run it