Pygame Installation¶
Pygame requires Python; if you don't already have it, you can download it from python.org. Use python 3.7.7 or greater, because it is much friendlier to newbies, and additionally runs faster.
How to install PyGame on the Mac OS X El Capitan 10.11.1. Install Anaconda 2.7; Get the SDL Framework run dmg and copy to /Library/Frameworks; brew install sdl note you need Homebrew installed. Install Pygame in Mac OS X # pygame # game # pip # install. Darkside haguremetal Apr 10, 2019 ・1 min read. Environment Mac OS X 10.14 Mojave; Anaconda3-5.3.1.
The best way to install pygame is with the pip tool (which is what python uses to install packages). Note, this comes with python in recent versions. We use the --user flag to tell it to install into the home directory, rather than globally.
To see if it works, run one of the included examples:
If it works, you are ready to go! If not there are more detailed, platform-specific instructions further down the page. Next steps...¶
You could try:
- Having a go at one of the tutorials.
- Or dive right into the pygame Docs
Further info on installation¶
Hopefully the installation instructions above worked for you. If not, please read some alternative installation methods, and extra details below.
Wheels are available for x86 and x64 architectures on Linux and Windows, and for x64 on Mac. If pip doesn't find a wheel for your platform, it will try to compile pygame from source (see below).
pygame requires a 'newer' pip. If pygame starts compiling from source and fails, first try upgrading pip.
Raspberry Pi¶
This comes with pygame already installed on the default raspbian installation.
Windows installation¶
Make sure you install python3.6 with the 'Add python 3.6 to PATH' option selected. This means that python, and pip will work for you from the command line.
There is documentation with python for the 'windows installation steps'
If you get 'PermissionError: [WinError 5] Access is denied', before starting the command prompt right click and 'Run as administrator'. Notice that this does not seem to work with Python 3.9 - use 3.7.
Mac installation¶
Recent versions of Mac OS X require pygame 2¶
If your examples aren't running and you are using a recent version of Mac OS X; try this line to install pygame instead:
virtualenv issue¶
There are problems with '
' and pygame on mac, where it loses focus. More details here: details on the virtualenv issue. It does work if you create a venv with python -m venv however. Instructions if you want to use an virtualenv (some people have trouble with the window losing focus when inside a venv).
![Free games for macbook pro Free games for macbook pro](/uploads/1/2/6/4/126405596/670923998.png)
Anaconda Mac¶
Use
instead of
(note the w on the end). If it doesn't work for you, please see the /wiki/MacCompile instructions.
Unix Binary Packages¶
Many Linux and BSD distributions have their own packages of Pygame. These may have an older version of Pygame than the wheels, but have been carefully tested with other packages in that distribution.
Debian/Ubuntu/Mint¶
Fedora/Red hat¶
OpenSUSE¶
Arch/Manjaro
Distribution | Python 3 package | Python 2 package | Debian/Ubuntu | python3-pygame | python-pygame | Fedora | python3-pygame | pygame |
---|
FreeBSD also has an active pygame package. While techinicaly it isn't binary, it is automatically built and installed by the ports manager. See the FreeBSD package page for more information. http://www.freebsdports.info/ports/devel/py-game.html
Gentoo has a builtin package for pygame. This is compiled for your system as it installs, similar to BSD, http://packages.gentoo.org/package/dev-python/pygame
Installing From Source¶
Compilation¶
Compiling and installing pygame is handled by Python's distutils. Pygame also comes with some scripts to automatically configure the flags needed to build pygame. Use the 'setup.py' script to start the installation.
The first time you run the setup script, it will call the 'config.py' script. This will build a 'Setup' file which stores all the information needed to compile. The 'config.py' will do a good job of detecting what dependencies are available and where they are located. If it isn't perfect, it is easy to build your own, or edit the created 'Setup' text file. This 'Setup' file is a simple Makefile-like text file. It defines variables needed to use each dependency, and then enables all the pygame modules with found dependencies. If you have trouble compiling, you should be able to easily fix any problems inside the 'Setup' file.
Running the 'setup.py' script will call distutils to build and install the pygame package. Distutils actually supports a wide variety of compile and install options. running 'python setup.py help' will start to show you the different options available. You can change many things like install locations, compiler to use, and more. Calling the 'setup.py' script with no arguments and it will just ask you if you want the default flags needed to compile and install.
Some of the .c files are generated by Cython from .pyx files. Running 'setup.py cython' will update them.
Windows Compiling Info
You can compile pygame on windows with mingw (gcc for windows) and also with visual studio. Up to date details can be found here: CompileWindows
Unix Compiling Info
Compiling from linux shouldn't give you any problems. One thing you must keep in mind is that most linux RPM packages separate the actual library from the 'dev' files needed to compile. To build you will need to make sure the packages like 'SDL-dev' are installed.
You can check to see if SDL is ready to be built from by running the command sdl-config and seeing if it is found. If the sdl-config script is not on the path (or you have more than one?) Set the environment variable SDL_CONFIG to its location. Sometimes you will have the SDL libraries installed in once location, and the other SDL libraries in another. This tricks the pygame config scripts, but you can help it out by setting the environment LOCALBASE to a path prefix where the other libraries are. The common case for this is SDL installed in /usr and other SDL libs installed in /usr/local. The command for this situation is 'LOCALBASE=/usr/local python setup.py install'.
Mac OS X Compiling Info¶
Up to date instructions for compiling on Mac OS X can be found here: MacCompile
if anaconda is installed¶
please deactivate base by:
then :
Mon, Sep 28, 2015Tags: pythonpygametutorial
Making games is a great way to improve your programming skills while making something fun at the same time. Pygame is a set of tools for Python that make it easy to work with graphics and sound.
Unfortunately, installing Pygame is not as easy as using it is. Below you’ll find the best directions we’ve found for getting it working on your system. Follow the directions below, and let us know in the comments below if you have any problems.
Note: For most of these instructions you will need to use the command line. Don’t be intimidated - programmers work on the command line all the time. Once you get used to it, you’ll find it’s the quickest and easiest way to do lots of useful things on the computer.
You access the command line by running the Terminal application - click on the Spotlight icon and type “terminal” to find it.
Step 1: Install XCode command line tools
XCode is the tool from Apple for creating Mac and iOS applications. It can be installed from the App Store (it’s free). When it’s finished, type the following at the command line:
Step 2: Install Homebrew (http://brew.sh)
Homebrew is a tool to easily install all kinds of software from the command line. It saves you having to go to a bunch of different sites and download lots of individual installers. Copy and paste this on the command line:
and follow the directions. You’ll also need to install Homebrew Cask (http://caskroom.io):
Step 3: Install the rest of the software
Now we can start installing all the requirements for Pygame. Just type the following commands one at a time and let the computer do its thing:
Step 4: See if it works!
Now we can see if it works. Run Python from the command line:
and try loading Pygame:
Pygame Download For Mac
If you don’t see an error message, you’re all set! Now head over to our YouTube Channel and start coding!
Important
You will not be able to use Pygame from IDLE. You will need to run your programs from the command line like this:
Some code editors will also let you run Python programs from inside the program, but we’ll talk about that in a separate post.
Step 1: Install Python
If you haven’t already, go to http://python.org/ and download the latest Python installer. Click on “Downloads” and choose “Download Python 3.5.0” (or whatever the latest version is).
When the download finishes, choose “run” - you may need to open your Downloads folder and double-click on the installer file.
Check the box labeled “Add Python 3.5 to PATH” and then click “Customize Installation”. Under “Optional Features” make sure all the boxes are checked. Under “Advanced Options” you can leave it as-is. Then click the Install button and let the computer complete the process.
Step 2: Install Pygame for Windows
Click here and download the appropriate installer for your computer. For most people, this will be the latest 32-bit installer, for example:
Choose “Save” and let the file download.
Now, you need to go to the command line. In your Start Menu search for “command” and you’ll see a button for “Command Prompt”.
Type the following:
Step3: See if it works!
Now we can see if it works. Run Python from the command line:
and try loading Pygame:
If you don’t see an error message, you’re all set! Now head over to our YouTube Channel and start coding!