ipygame
ipygame is a pygame-style API for writing small games inside Jupyter notebooks, primarily for teaching and classroom use. Instead of SDL2, it renders to an ipycanvas canvas output, so it works in environments where you do not have a desktop window (e.g. JupyterLab, hosted JupyterHub).
PacMan running with
ipygame. Credit: https://github.com/AnandSrikumar/PyPacman
The goal is API familiarity, not perfect drop-in compatibility. Many common drawing and event patterns work, but the browser and the widget stack impose limits. Audio works as well; but it's currently experimental.
Install
For local notebooks (CPython kernels), install from PyPI:
pip install ipygame
or from source:
pip install git+https://github.com/Kamuyin/ipygame.git
Quick start
import ipygame as pygame
screen = pygame.display.set_mode((420, 260))
screen.fill("midnightblue")
pygame.draw.rect(screen, "gold", (30, 30, 140, 80))
pygame.draw.circle(screen, "tomato", (280, 130), 50)
pygame.display.flip()
You might also want to temporarily register ipygame as the pygame package if you already have a codebase that uses pygame.
import ipygame
pygame.install_hook()
# Then the kernel always uses `ipygame` without the need to adjust your codebase.
Examples
The examples/ folder contains notebooks for basic drawing, input handling, and small game demos.
Documentation
Docs and API reference: https://kamuyin.github.io/ipygame
Limitations and known issues
Some pygame features are not applicable in the browser or are not implemented yet. For a high-level view of what is currently covered, check the API coverage page in the docs.
Performance can be noticeably lower than desktop pygame. Rendering happens through the browser canvas and a widget message channel, so high-FPS loops and pixel-heavy effects pay extra overhead, and there is no native SDL2 window/GPU pipeline like on the desktop.
If you run the examples in JupyterLite (Pyodide), you may see rendering work while real-time keyboard/mouse input does not. This is a limitation of the Pyodide kernel + widget message processing for long-running loops, and it is not something ipygame can reliably fix from Python alone.
Acknowledgements
ipygame is based on the work by the pygame and pygame-ce projects and aims to provide a familiar API for educational notebooks. This project is not affiliated with, endorsed by, or a replacement for pygame/pygame-ce.
License
Licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1-only). See LICENSE.
Metadata
Release files for ipygame 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipygame-1.0.1.tar.gz | 398.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipygame-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 474.2 kB
Release files / ipygame-1.0.1.tar.gz
| Download URL | ipygame-1.0.1.tar.gz |
|---|---|
| Size | 398.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e30b44f9645441e1a88a7f4dfbf40593d81bf8928e0055d4874e36d78ca65ef
|
|
BLAKE2b-256 checksum How to use checksums |
aed45552c6bc80d32f6730671682a05ac98db97be4d082c9e835df73f0293aed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency logRelease files / ipygame-1.0.1-py3-none-any.whl
| Download URL | ipygame-1.0.1-py3-none-any.whl |
|---|---|
| Size | 75.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
210d350570c6fc2077be12a1bd8b458f34b4c107a3fb63a27ce73606542ba72a
|
|
BLAKE2b-256 checksum How to use checksums |
5a399cbf2b8724de8b2e67c5f28bb56ee9c8b9985c8396c7c1e797a2fd6fef77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency log