beautifultable
beautifultable is a Python library for printing beautiful, structured text tables in terminals, making CLI output more readable. Its current stable version is 1.1.0, released in January 2020. The project appears stable and feature-complete but has not seen active development or new releases since 2020, so its release cadence is infrequent.
Common errors
-
AttributeError: 'BeautifulTable' object has no attribute 'append_row'
cause Attempting to use the `append_row` method from `beautifultable` version 0.x on a 1.x installation.fixThe `append_row` method was replaced. Use `table.rows.append(data_list)` instead for `beautifultable` versions 1.0.0 and later. -
NameError: name 'BeautifulTable' is not defined
cause The `BeautifulTable` class was not imported into the current scope.fixAdd `from beautifultable import BeautifulTable` at the top of your Python file or before using the class. -
TypeError: The value for 'width' must be a positive number.
cause Incorrectly trying to set the overall table width using an attribute that no longer exists or expects a specific type/range, or using a method from a previous API version.fixFor the maximum table width, use `table.max_width = <integer>`. For individual column widths, use `table.columns.width = {column_name: width}` or `table.columns.width[column_name] = width`.
Warnings
- breaking Version 1.0.0 introduced a complete rewrite of the API. Many methods and attributes from 0.x versions (e.g., `append_row`, `column_headers`, `set_width`) were removed or replaced with new object-oriented interfaces (e.g., `table.rows.append`, `table.columns.header`, `table.max_width`).
- gotcha The project has not been actively maintained since its last release in January 2020. While stable for its intended use, this means there will be no new features, security updates, or bug fixes for any newly discovered issues.
- gotcha When handling mixed data types or special characters, `beautifultable` might require explicit type casting or alignment settings. Incorrect numeric precision or text wrapping can lead to unaligned columns.
Install
-
pip install beautifultable
Imports
- BeautifulTable
from beautifultable import BeautifulTable
Quickstart
from beautifultable import BeautifulTable table = BeautifulTable() table.columns.header = ["Name", "Age", "City"] table.rows.append(["John", 30, "New York"]) table.rows.append(["Jane", 25, "London"]) table.rows.append(["Doe", 35, "Paris"]) # Example of setting column alignment table.columns.align["Age"] = BeautifulTable.ALIGN_RIGHT print(table)