Install & Compatibility
Where this runs
tested against v1.2.7 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.106s · 30.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.6s · import 0.100s · 31MB
29MB installed
● package 29MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Console
✓ from enrich.console import Console
✗ from rich.console import Console
The `enrich` Console class includes additional features like `redirect` and `soft_wrap` parameters not present in the original `rich.console.Console`.
RichHandler
✓ from enrich.logging import RichHandler
✗ from rich.logging import RichHandler
The `enrich` RichHandler provides an alternative logging handler, notably with soft-wrapping behavior, differing from the standard `rich` handler.
This quickstart demonstrates key features of the `enrich` library: a `Console` instance configured to redirect `sys.stdout` and capture output, another `Console` instance with implicit soft-wrapping enabled for print statements, and the `RichHandler` configured for soft-wrapping in standard Python logging.
import logging
from enrich.console import Console
from enrich.logging import RichHandler
import sys
# Example 1: Console with redirect support
console_redirect = Console(redirect=True, record=True)
original_stdout = sys.stdout
sys.stdout = console_redirect.fileproxy
print("This output is redirected and recorded.")
sys.stdout = original_stdout # Restore stdout
# print(f"Captured output: {console_redirect.export_text()}") # Use this to see recorded text
# Example 2: Console with implicit soft wrapping
console_soft_wrap = Console(soft_wrap=True)
console_soft_wrap.print("This is a very long line of text that will be soft-wrapped by the console instance, ensuring it fits within any terminal width without explicit print arguments.")
# Example 3: Soft-wrapping logger
FORMAT = "%(message)s"
logging.basicConfig(
level="INFO", format=FORMAT, handlers=[RichHandler(soft_wrap=True)]
)
log = logging.getLogger("my_app")
log.info("This log message will also be soft-wrapped.")
log.info("Another long message demonstrating the soft-wrapping logger functionality.")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'enrich'
The 'enrich' library is not installed in the current Python environment, or the environment where the code is being run does not have access to the installed library.
fixInstall the library using pip: `pip install enrich`
TypeError: __init__() got an unexpected keyword argument 'redirect'
This error occurs when attempting to use the `redirect=True` argument with the standard `rich.console.Console` class, but this specific argument is an enhancement provided only by the `enrich.console.Console` class.
fixEnsure you are importing and using the `Console` class from `enrich.console` instead of `rich.console`: `from enrich.console import Console`
TypeError: __init__() got an unexpected keyword argument 'soft_wrap'
This error arises when trying to pass the `soft_wrap=True` argument directly to the `rich.console.Console` constructor. Implicit soft wrapping in the `Console` constructor is a feature added by the `enrich` library.
fixImport and use the `Console` class from `enrich.console` to leverage its soft-wrapping capabilities: `from enrich.console import Console`
TypeError: __init__() got an unexpected keyword argument 'soft_wrap'
The `enrich.logging.RichHandler` inherently provides soft-wrapping behavior by internally using an `enrich.console.Console` instance configured for it. Passing `soft_wrap` as an explicit argument to the `RichHandler` constructor is not supported.
fixRemove the `soft_wrap` argument when initializing `enrich.logging.RichHandler`, as its soft-wrapping is managed internally. For example: `from enrich.logging import RichHandler; handler = RichHandler()`
Upgrade
Version history
1.2.7latest on PyPI · released Jan 10, 2022
Audit
Dependencies
richrequiredCore dependency; 'enrich' extends 'rich' functionality.