Install & Compatibility
Where this runs
tested against v0.9.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.048s · 19.3MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.5s · import 0.048s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PrettyTable
✓ from prettytable import PrettyTable
✗ from ptable import PTable
Despite the package name `PTable`, the main class is `PrettyTable` and is imported from the `prettytable` namespace due to its origin as a fork.
This quickstart demonstrates creating a PrettyTable instance, defining column headers using `field_names`, adding data row by row with `add_row`, and then printing the table to the console. It also shows how to get an HTML string representation.
from prettytable import PrettyTable
# Create a new table
x = PrettyTable()
# Set field names
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
# Add rows
x.add_row(["Adelaide", 1295, 1158259, 600.5])
x.add_row(["Brisbane", 5905, 1857594, 1146.4])
x.add_row(["Darwin", 112, 120900, 1714.7])
# Print the table (implicitly calls __str__ for ASCII representation)
print(x)
# Get HTML string representation
html_table = x.get_html_string()
# print(html_table) # Uncomment to see HTML output
Debug
Known issues
breakingThe `x.printt()` method, available in versions 0.5 and earlier, has been removed.fixUse `print(x)` for direct output or `x.get_string()` to obtain the ASCII table as a string.
affects: <=0.5
gotchaPTable uses the `prettytable` namespace for its imports (`from prettytable import PrettyTable`), which can lead to conflicts or unexpected behavior if the original `prettytable` library is also installed in the same environment.fixAvoid installing both `PTable` and `prettytable` simultaneously. If you need functionality from `PTable`, ensure only it is installed, or manage environments carefully.
affects: All versions
deprecatedThe library has not been updated since version 0.9.2 in May 2015. This indicates a lack of active maintenance and may lead to compatibility issues with newer Python versions or unaddressed bugs.fixConsider alternatives like the actively maintained `PrettyTable` if long-term support and modern Python compatibility are critical. Otherwise, be aware that future Python updates might break functionality.
affects: 0.9.2 and earlier
Errors
Common errors & fixes
ImportError: cannot import name 'PTable' from 'ptable'
The main class is named `PrettyTable` and is imported from the `prettytable` module, even when the package installed is `PTable`.
fixUse `from prettytable import PrettyTable` instead of `from ptable import PTable`.
AttributeError: 'PrettyTable' object has no attribute 'printt'
You are attempting to use the deprecated `printt()` method, which was removed in versions 0.6 and later.
fixReplace `x.printt()` with `print(x)` or `print(x.get_string())`.
Unexpected table formatting or missing features when both PTable and prettytable are installed.
Due to `PTable` being a fork of `PrettyTable` and using the same internal `prettytable` namespace, having both packages installed can cause Python to load an unpredictable version of the library, leading to inconsistent behavior.
fixUninstall one of the packages. If you intend to use the `PTable` fork, ensure only `pip uninstall prettytable` is performed, then `pip install PTable`. Vice-versa if you prefer the original `prettytable`.
Upgrade
Version history
0.9.2latest on PyPI · released May 28, 2015
Audit
Dependencies
No dependency data recorded yet.