Guide · Open source
How to use Rich: print colour, tables and progress bars in Python
Updated · written with AI from the project's own documentation and checked against our catalogue data
Rich is a Python library that adds color, style and formatted layouts to terminal output. This guide is for Python developers and learners who want clearer command-line output. By the end you will be able to install Rich, print styled text, use the Console object and render a table.
Quick start
- 1Check your Python version. Rich requires Python 3.8 or later. Confirm this before you install.
- 2Install Rich. Run python -m pip install rich in your terminal or virtual environment.
- 3Run the demo. Run python -m rich to see the output your terminal supports.
- 4Try rich print. Import print from rich in a script and add a style tag such as [bold magenta] to a string.
- 5Create a Console. Import Console from rich.console, create an object and call its print method.
- 6Build a table. Import Table from rich.table, add columns and rows, then print the table through a Console.
Install Rich with pip
Rich is installed from PyPI with pip. The README says it requires Python 3.8 or later and works on Linux, macOS and Windows.
- Requires Python 3.8 or later.
- Run the install command from your terminal or virtual environment.
python -m pip install richTest Rich output in your terminal
After installing, you can run Rich's built-in demo to see what your terminal can display. The README notes that the classic Windows terminal is limited to 16 colors, while the new Windows Terminal supports true color and emoji.
python -m richUse rich print as a drop-in replacement
The simplest way to start is to import print from rich. It has the same signature as Python's built-in print function, but it accepts style markup inside the string.
- Wrap text in tags such as [bold magenta] and close them with [/bold magenta].
- Emoji names between colons, such as :vampire:, are converted to symbols.
from rich import print
print("Hello, [bold magenta]World[/bold magenta]!", ":vampire:", locals())Create a Console object for finer control
For more control, import Console and create an object. Its print method has an interface similar to the built-in print. Unlike the built-in, Rich word-wraps text to fit the terminal width.
You can style a whole line with the style keyword, or style parts of a line with Rich's markup, which the README describes as similar in syntax to BBCode.
- Use style="bold red" to style an entire output line.
- Use markup such as [u]text[/u] or [i]text[/i] for part of a line.
from rich.console import Console
console = Console()
console.print("Hello", "World!", style="bold red")
console.print("Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i].")Render a table
Rich can render tables with Unicode box characters. You create a Table, add columns, then add rows. The README lists options for borders, styles and cell alignment.
- Set show_header and header_style on the Table.
- Use add_column to define each column, with optional style and width.
from rich.console import Console
from rich.table import Table
console = Console()
table = Table(show_header=True, header_style="bold magenta")
table.add_column("Date", style="dim", width=12)Use log and pretty printing for debugging
The Console log method works like print but also shows the current time and the file and line that made the call. If you pass log_locals=True, Rich outputs a table of the local variables at that point. Collections such as dicts and lists are pretty printed to fit the available space.
The README notes that log could be used for long-running applications such as servers, and is also a useful debugging aid.
console.log(test_data, log_locals=True)What people use it for
- Adding colour and emphasis to the output of a command-line script.
- Logging with timestamps and local variable tables while a long-running Python program runs.
- Showing a formatted table of results in a terminal without laying out the columns by hand.
- Pretty printing data structures in the Python REPL after running pretty.install().
Frequently asked questions
Is Rich free to use?
Rich is released under the MIT licence, as stated in the project's listing. You can read the licence text in the repository to confirm the terms for your use.
What are the requirements for Rich?
The README says Rich requires Python 3.8 or later and works with Linux, macOS and Windows. It also works in Jupyter notebooks with no extra configuration.
How do I install Rich?
Run python -m pip install rich. The README says you can also use another PyPI package manager.
Why are my colours not showing on Windows?
The README says the classic Windows terminal is limited to 16 colors. True color and emoji work in the new Windows Terminal.
Is Rich an application or a library?
Rich is a library. You import it into your own Python code. If you only need a finished application, the README suggests looking elsewhere.
How does Rich compare to Textual, Click, tqdm or colorama?
This directory lists Textual, Click, tqdm and colorama as comparable projects. Rich focuses on formatted output such as tables, progress bars and markup, while Textual builds full terminal applications. Check each project's documentation to decide which fits your task.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Rich is a good fit for Python developers who want clearer terminal output, tables, progress bars or debugging logs without building layouts by hand. It is not suited to non-Python projects, to users who need a finished application rather than a library, or to environments limited to the classic Windows terminal's 16 colors.
Install options & downloads