Sait Sait - 5 months ago 31
Python Question

Installing pygame with homebrew

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.

cel cel
Answer

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