Installing PySDL2

This section provides an overview and guidance for installing PySDL2 on various target platforms.

Using pip

The easiest way to get up and running with PySDL2 is to install it and the SDL2 binaries it depends on using the Pip package manager

python -m pip install pysdl2 pysdl2-dll

Note that the pysdl2-dll binaries may not be available yet for your platform. If not, please read through the Prerequisites section below.

Installing from source

You can download the official releases of PySDL2 from Download the most recent release, unpack it and make sure that you installed the relevant prerequisites before continuing with the installation.

Then, you can install PySDL2 directly with Python

python install


PySDL2 relies on some additional libraries to be fully usable and to provide you full access to all of its features.

You must have at least one of the following Python versions installed:

Other Python versions or Python implementations might work, but are (currently) not officially tested or supported by the PySDL2 distribution.

You need to have a working SDL2 library on your target system. On Windows (32-bit and 64-bit x86), macOS (64-bit x86), and Linux (32-bit/64-bit x86, and 64-bit ARM), you can install the latest official binaries with pip via the pysdl2-dll package. Alternatively, you can install it using your system’s package manager, download the official binaries from, or compile it from source yourself.

PySDL2 also offers optional support for the following SDL-related libraries:

However, these are only necessary if you want to use the sdl2.sdlimage, sdl2.sdlmixer, sdl2.sdlttf or sdl2.sdlgfx modules. Binaries for all these modules are provided by the pysdl2-dll package.

Trying out

You also can test out PySDL2 without actually installing it. You just need to set up your PYTHONPATH to point to the location of the source distribution package. On Windows-based platforms, you might use something like

set PYTHONPATH=C:\path\to\pysdl2\:%PYTHONPATH%

to define the PYTHONPATH on a command shell. On Linux/Unix, use

export PYTHONPATH=/path/to/pysdl2:$PYTHONPATH

for bourne shell compatibles or

setenv PYTHONPATH /path/to/pysdl2:$PYTHONPATH

for C shell compatibles. You can omit the :$PYTHONPATH, if you did not use it so far and if your environment settings do not define it.


If you did not install SDL2 using the preferred way for your operation system, please read the information about Bundling SDL2 with pysdl2-dll in the section Integrating PySDL2.