This page covers how to install Rich and the primary entry points for using it: rich.print() as a drop-in replacement for Python's built-in print, pretty.install() for REPL enhancement, the python -m rich demo command, and basic Console instantiation. For a broader architectural overview of how these pieces fit together internally, see Architecture Overview. For the full Console API reference, see Console.
Rich requires Python 3.8 or later and runs on Linux, macOS, and Windows.
| Platform | Notes |
|---|---|
| Linux / macOS | Full color and emoji support |
| Windows (new Terminal) | Full truecolor and emoji support |
Windows (classic cmd.exe) | Limited to 16 colors |
| Jupyter notebooks | Supported with no extra configuration |
Install via pip:
Install via Poetry:
Install with Jupyter extras (adds ipywidgets support):
The core runtime dependencies, as declared in pyproject.toml30-35 are:
| Dependency | Purpose |
|---|---|
pygments >= 2.13.0 | Syntax highlighting |
markdown-it-py >= 2.2.0 | Markdown rendering |
ipywidgets (optional) | Jupyter widget integration |
Sources: pyproject.toml1-51 README.md41-58 docs/source/introduction.rst8-28
After installing, run the built-in demo to confirm Rich is working and to preview its capabilities:
This executes rich/__main__.py and renders a showcase of Rich's output features — tables, syntax highlighting, panels, progress bars, and more — directly to your terminal.
Sources: README.md54-58 docs/source/introduction.rst33-39
rich.print()The fastest way to add Rich output to any script is to import rich.print. It has the same signature as Python's built-in print and can be used as a direct drop-in replacement.
This single import enables:
[bold magenta]...[/bold magenta]:vampire:If you want to avoid shadowing the built-in, import it under an alias:
rich.print is defined in rich/__init__.py and internally constructs a default Console instance and calls its print method.
Entry point flow for rich.print():
Sources: README.md60-78 docs/source/introduction.rst43-76
pretty.install()Rich can be installed into the Python REPL so that any evaluated expression is automatically pretty-printed with syntax highlighting, replacing Python's default sys.displayhook.
After calling pretty.install(), any data structure printed in the REPL — dicts, lists, dataclasses, etc. — will be formatted by Rich's pretty-printer.
You can also preview Rich renderables interactively in the REPL:
Rich ships an IPython extension that installs both pretty-printing and rich tracebacks:
To load it automatically on every IPython startup, add "rich" to the c.InteractiveShellApp.extension list in your IPython configuration.
How pretty.install() hooks into the Python session:
Sources: README.md73-81 docs/source/introduction.rst79-112
Console ClassFor more control over output, instantiate a Console directly from rich.console.
The Console constructor accepts many optional parameters. The most commonly used ones at this stage:
| Parameter | Type | Description |
|---|---|---|
stderr | bool | Write to stderr instead of stdout |
style | str | Default style applied to all output |
width | int | Override detected terminal width |
highlight | bool | Enable/disable automatic syntax highlighting |
markup | bool | Enable/disable console markup parsing |
theme | Theme | Custom Theme object for named styles |
record | bool | Buffer output for later export |
quiet | bool | Suppress all output |
A default Console() with no arguments will auto-detect the terminal width and color capabilities.
console.print()Unlike the built-in print, console.print automatically word-wraps text to fit the terminal width.
ConsoleSources: README.md83-119 docs/source/introduction.rst43-76
| Use Case | Recommended Entry Point |
|---|---|
| Quick script with styled output | from rich import print |
| Interactive REPL sessions | from rich import pretty; pretty.install() |
| IPython / Jupyter enhancement | %load_ext rich |
| Structured output (tables, panels, etc.) | from rich.console import Console |
| Logging integration | RichHandler — see Logging Integration |
| Pretty tracebacks | rich.traceback.install() — see Traceback Enhancement |
Sources: README.md60-134 docs/source/introduction.rst43-113
Console, Text, Segment, and renderable subsystems fit together, see Architecture Overview.Console class reference including all constructor parameters and methods, see Console.pretty module in depth, including pretty_repr() and the __rich_repr__ protocol, see Pretty Printing and REPL.Refresh this wiki
This wiki was recently refreshed. Please wait 2 days to refresh again.