- Open the Terminal.
- Install Homebrew.
- If you run into issues with OS X El Capitan, this will help.
- Enable the Xcode Command Line Tools, necessary for installing/compiling Homebrew:
xcode-select –install
- Then install Homebrew itself:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 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.
- Install prerequisites for pygame:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi mercurial
- Install pygame using
pip
withpip install hg+http://bitbucket.org/pygame/pygame
- 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.
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 usexcode-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