Texttable
raw JSON → 1.7.0 verified Tue May 12 auth: no python install: verified
Texttable is a Python module to create simple ASCII tables. It provides an easy-to-use API for formatting data into human-readable text tables, supporting various alignments, data types, and decorative options. The current version is 1.7.0, and it is actively maintained with regular updates.
pip install texttable Common errors
error IndexError: list index out of range ↓
cause This error occurs when `add_row()` is called with a number of cells that does not match the implicitly or explicitly defined number of columns for the table.
fix
Ensure each list passed to
add_row() contains the same number of elements as the table's total column count, which is often determined by the first row added or methods like set_cols_align. error TypeError: set_cols_dtype() takes 2 positional arguments but X were given ↓
cause The `set_cols_dtype` method expects a single iterable (list or tuple) containing type codes as its `dtypes` argument, not separate arguments for each column.
fix
Pass a list or tuple of type codes to
set_cols_dtype, even if defining the type for only one column, e.g., table.set_cols_dtype(['t', 'f']). error ValueError: Unknown type specified for column ↓
cause An invalid character or unsupported type code was provided in the list of data types for the `set_cols_dtype` method.
fix
Use one of the supported type codes: 't' (text), 'f' (float), 'e' (scientific), 'i' (integer), 'a' (auto), 'd' (date).
error ImportError: cannot import name 'texttable' from 'texttable' ↓
cause The main class in the `texttable` library is named `Texttable` (with a capital 'T'), but the import statement attempted to use a lowercase 't'.
fix
Correct the capitalization in the import statement:
from texttable import Texttable. Warnings
gotcha Automatic column data type detection can lead to unexpected formatting, especially for numbers like `1.0` or `0.0` which might be converted to integers instead of floats. Always explicitly set column data types using `set_cols_dtype()` if precise formatting is needed. ↓
fix Call `table.set_cols_dtype(['t', 'f', 'i', 'a'])` before adding rows to define how each column's data should be handled (text, float, integer, auto).
gotcha The `max_width` parameter in the `Texttable` constructor can cause cell content to wrap if the content exceeds the calculated column width. Setting `max_width=0` allows the table to self-adjust and prevents wrapping, ensuring all content appears on a single line where possible. ↓
fix Initialize `Texttable` with `table = Texttable(max_width=0)` for a dynamically sized table, or carefully manage `max_width` if wrapping is desired.
breaking Version 1.6.5 introduced a regression where stub files were missing in the wheel package, potentially causing import or packaging issues for some users. ↓
fix Upgrade to version 1.6.6 or later, which includes a fix for this regression.
deprecated The behavior of boolean values in table cells was improved with a dedicated formatting option in version 1.7.0. Older versions might not format booleans as intuitively or consistently. ↓
fix Upgrade to version 1.7.0 or newer to leverage the enhanced boolean formatting capabilities.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 0.00s 17.8M
3.10 alpine (musl) - - 0.00s 17.8M
3.10 slim (glibc) wheel 1.4s 0.00s 18M
3.10 slim (glibc) - - 0.00s 18M
3.11 alpine (musl) wheel - 0.01s 19.7M
3.11 alpine (musl) - - 0.01s 19.7M
3.11 slim (glibc) wheel 1.6s 0.01s 20M
3.11 slim (glibc) - - 0.01s 20M
3.12 alpine (musl) wheel - 0.01s 11.6M
3.12 alpine (musl) - - 0.01s 11.6M
3.12 slim (glibc) wheel 1.4s 0.01s 12M
3.12 slim (glibc) - - 0.01s 12M
3.13 alpine (musl) wheel - 0.01s 11.3M
3.13 alpine (musl) - - 0.01s 11.2M
3.13 slim (glibc) wheel 1.4s 0.01s 12M
3.13 slim (glibc) - - 0.01s 12M
3.9 alpine (musl) wheel - 0.00s 17.3M
3.9 alpine (musl) - - 0.00s 17.3M
3.9 slim (glibc) wheel 1.7s 0.00s 18M
3.9 slim (glibc) - - 0.00s 18M
Imports
- Texttable
from texttable import Texttable
Quickstart last tested: 2026-04-24
from texttable import Texttable
table = Texttable()
# Set column alignments (left, right, center)
table.set_cols_align(["l", "r", "c"])
# Set column data types (text, float, integer)
table.set_cols_dtype(["t", "f", "i"])
# Add a header row
table.header(["Name", "Score", "Rank"])
# Add rows of data
table.add_row(["Alice", 95.5, 1])
table.add_row(["Bob", 88.0, 2])
table.add_row(["Charlie", 72.3, 3])
# Draw and print the table
print(table.draw())