MacOS – pygame installed through homebrew does not work

homebrewmacospython

I ran brew install pygame, it installed it together with all the dependencies. Python v2.7.10 / OS X version 10.11.2

Whenever I import pygame in a script it says this

Traceback (most recent call last):
 File "~/Documents/test.py", line 1, in <module>
import pygame, random, sys
ImportError: No module named pygame

How do I fix this?

Best Answer

Have you checked which python are you running - the system python or the one you installed via homebrew? I suspect the first.

As a test, try running

/usr/local/Cellar/python/2.7.10/bin/python

and typing

>> import pygame

If this works, you can make the brew version the default by using:

brew link python