How To Download Pygame On Mac
Posted : admin On 11/2/2019How to install PyGame for Python 3 PyGame is a set of python modules designed for writing games. It uses the SDL library to allow you to create games and multimedia programs in Python. Jun 13, 2018 Installing Python and Pygame for Mac Zenva. Unsubscribe from Zenva? Download & Install Pygame for Python 3.7+ Using the Pip Package - Duration: 4:30.
- Open the Terminal.
- Install Homebrew.
- 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
.
Pygame Install Windows
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.
Example
On windows
Navigate to http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame – an unofficial site providing windows binaries of open-source python packages for the official CPython distribution by Christoph Gohlke.
Download the appropriate pygame
.whl
file according to your installed python version. (The file is named something likepygame -
<pygame version> - <python version>
- win32.whl
)Run
inside your terminal, bash or consol.
Note: ifpip
is not found inPATH
try to runpython -m pip install your-pygame-package.whl
Check if you can import pygame as a python module
If you do not get an error, you have correctly installed pygame on your computer :)
On linux
Open your terminal and run
Note: This will install pygame for python2
Try to import pygame inside
If you do not get an error, you have correctly installed pygame on your linux system :)
On macOS
There are two ways to install it on mac:
Pygame Download For Python 3.7
Method 1
Go to the Pygame downloads page and download the mac installer. Run it, and it should install Pygame on your Mac.
Method 2
Install Homebrew: Dmg extractor.
Then use Homebrew to install Python 2.7.12 and Pygame:
Now run Python in your terminal and try import pygame
. If it does not say anything, it's installed successfully.