Registry / serialization / asciitree

asciitree

JSON →
library0.3.3pypypi✓ verified 23d ago

asciitree is a Python library that enables the drawing of tree structures using ASCII characters directly in the terminal. It is currently at version 0.3.3, with its last release in 2016, suggesting a maintenance or inactive release cadence.

pip install asciitree
INSTALL
IMPORT
SIG · ASCIITREE
A
asciitree
serializationpythonv0.3.3
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.3 · 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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LeftAligned
from asciitree import LeftAligned
from ascii_tree import make_and_print_tree
While some older examples or alternative libraries might use `ascii_tree`, the core library and its primary documentation use `from asciitree import LeftAligned` for rendering.

This quickstart demonstrates how to create a hierarchical dictionary structure, using `OrderedDict` for predictable child ordering, and then render it into an ASCII tree using the `LeftAligned` renderer.

from asciitree import LeftAligned from collections import OrderedDict as OD tree_data = { 'root': OD([ ('child1', { 'grandchild1_1': {}, 'grandchild1_2': {'subgrandchild': {}} }), ('child2', { 'grandchild2_1': {}, }), ('child3', {}) ]) } tr = LeftAligned() print(tr(tree_data))
Debug
Known issues
deprecatedThe library has not been updated since September 2016. While it functions, it may not receive further bug fixes or new features and might have compatibility issues with very recent Python versions or dependencies not yet discovered.
fix
Consider testing thoroughly with your target Python environment. For new projects, evaluate more actively maintained alternatives if long-term support is crucial.
affects: <=0.3.3
gotchaThe library explicitly states support only for Python 3. Attempting to use it with Python 2 environments will likely result in errors.
fix
Ensure your project's environment is running Python 3 or higher.
affects: <=0.3.3
gotchaThere are multiple Python, Go, and JavaScript libraries that share the 'asciitree' or 'ascii tree' name. Ensure you are importing and using the correct Python library 'asciitree' by Marc Brinkmann (mbr).
fix
Always verify the PyPI package name and the GitHub repository (`mbr/asciitree`) to ensure you are using the intended library.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'asciitree'
The 'asciitree' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install asciitree'.
ImportError: cannot import name 'LeftAligned' from 'asciitree'
The 'LeftAligned' class is not available in the 'asciitree' module.
fix
Ensure you are using the correct import statement: 'from asciitree import LeftAligned'.
TypeError: 'NoneType' object is not callable
Attempting to call a function or method that is None, possibly due to incorrect initialization.
fix
Verify that all objects are properly initialized before calling their methods.
AttributeError: 'dict' object has no attribute 'children'
The `asciitree` library, by default, uses `DictTraversal` which expects a dictionary structure where values are also dictionaries for children. If you attempt to use a custom traversal or pass an object that does not conform to this expectation, or an explicit `AttributeTraversal` when the nodes don't have a 'children' attribute, this error can occur.
fix
Ensure your tree data is structured as nested dictionaries as expected by `DictTraversal`, or define a custom traversal method (e.g., `AttributeTraversal`) and ensure your node objects have a `children` attribute, or implement the dictionary interface correctly for your nodes.
UnicodeEncodeError: 'ascii' codec can't encode characters
This error often arises when running `asciitree` code in older Python 2 environments or with misconfigured encodings in Python 3, as the library deals with ASCII and potentially other characters for tree drawing.
fix
Ensure you are running your code in a Python 3 environment, as `asciitree` explicitly supports Python 3. If the issue persists, explicitly set the encoding of your terminal or output stream to UTF-8.
Upgrade
Version history
0.3.3latest on PyPI · released Sep 5, 2016
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
asciitree — pip install asciitree · libregistry