chess
A chess library with move generation and validation, Polyglot opening book probing, PGN reading and writing, Gaviota tablebase probing, Syzygy tablebase probing, and XBoard/UCI engine communication.
What it is and what it does
python-chess is a pure-Python library for representing, manipulating, and analyzing chess positions and games. It handles move generation and validation, board representation in multiple formats (FEN, EPD, Shredder FEN), and detection of game-ending conditions (checkmate, stalemate, draws). It reads and writes PGN files with comments and variations, probes Polyglot opening books and Syzygy/Gaviota endgame tablebases, and communicates with UCI and XBoard chess engines via asyncio.
The library has no runtime dependencies and includes full type hints. It supports standard chess and variants (Chess960, Atomic, Crazyhouse, and others), integrates with IPython/Jupyter for board visualization, and is actively maintained across modern Python versions. High install friction stems from source-only distribution, though the codebase is stable and production-ready.
Use it for:
- Build a chess engine or analysis tool that validates moves and probes endgame tables.
- Parse and replay historical games from PGN files with full move and variation tracking.
- Communicate with external engines (Stockfish, etc.) to evaluate positions and generate best moves.
- Implement chess variants or custom game rules on top of the board representation.
- Analyze opening theory by reading Polyglot opening books and generating legal move sequences.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pure-Python chess library providing move generation, validation, and support for standard chess formats (FEN, PGN, EPD) plus engine communication and endgame tablebase probing.
Yes, for chess applications and analysis tools. The library is stable, actively maintained, and provides a comprehensive pure-Python API with no external runtime dependencies. The GPL-3.0+ copyleft license is appropriate for open-source projects but requires review for proprietary use. High install friction (source distribution) is a minor friction point but not a blocker for most workflows.
Install
chess on PyPI
pip
pip install chessuv
uv add chesspoetry
poetry add chessInstalling chess
Before you install
High install friction due to source distribution; no runtime dependencies. Actively maintained with recent commits and stable production status across Python 3.8–3.13.
License in practice
GPL-3.0+ copyleft license requires derivative works to be licensed under GPL-3.0 or later; suitable for open-source projects but may restrict commercial or proprietary use.
Quickstart
pip install chess
import chess
board = chess.Board()
board.push_san("e4")
print(board.legal_moves)
Requires Python 3.8 or later.
Verify before relying
- Whether high install friction (source-only distribution) impacts typical deployment workflows or CI/CD pipelines.
- Performance characteristics for large-scale move generation or tablebase queries relative to compiled alternatives.
Package facts
| License | GPL-3.0+ (copyleft) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 535 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,739,913/month — #2,510 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: chess-1.11.2.tar.gz
Keywords: chess, fen, epd, pgn, polyglot, syzygy, gaviota, uci, xboard
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
python-chesspython-chess provides move generation, move…
copyleft · top 5,000 on PyPI
stockfishWraps the Stockfish chess engine to let Python…
permissive · top 5,000 on PyPI
nashpyNashpy computes Nash equilibria and simulates…
permissive · top 5,000 on PyPI
open-spielOpenSpiel provides game environments and…
permissive · top 15,000 on PyPI
Box2DBox2D is a Python binding to the Box2D C++…
permissive · top 15,000 on PyPI
pygletpyglet is a cross-platform windowing and…
unclear · top 5,000 on PyPI
memcache-hybridProvides Python bindings for a high-performance…
unclear · top 15,000 on PyPI
PyDirectInputAutomates mouse and keyboard input on Windows…
permissive · top 15,000 on PyPI