Registry / autopage

autopage

JSON →
library0.6.0pypypi✓ verified 23d ago

Autopage is a Python library designed to automatically display terminal output from a program in a pager (like `less`) when the output is extensive, and behave normally otherwise. It ensures consistent, user-friendly console output, preserves colors, and correctly handles output redirection. The current version is 0.6.0, released on January 29, 2026. While there isn't a strict stated release cadence, releases tend to be infrequent, occurring roughly every 6-18 months.

pip install autopage
INSTALL
IMPORT
SIG · AUTOPAGE
A
autopage
pythonv0.6.0
Install
1.5s avg
Import
24ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.0 · 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.026s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.022s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

AutoPager
from autopage import AutoPager
monkey_patch (for argparse)
import autopage.argparse autopage.argparse.monkey_patch()
Used to automatically page help output for `argparse` based CLIs. Can also be used as a context manager.

This quickstart demonstrates how to use `autopage.AutoPager` as a context manager to pipe extensive console output through a system pager (like `less`). It generates a large amount of text, first printing it directly to `stdout` and then routing it through `AutoPager` to show the difference. For `autopage` to function, a pager (e.g., `less`) must be installed and accessible in the system's PATH.

import sys import autopage # Function to generate lines of text def generate_lines(num_lines): for i in range(1, num_lines + 1): yield f"This is line {i} of the generated output. " * 5 + "\n" if __name__ == "__main__": print("--- Output without autopage (might scroll rapidly) ---") for line in generate_lines(20): # Generate a few lines sys.stdout.write(line) print("--- End without autopage ---\n") print("--- Output with autopage (will use a pager like 'less' if output exceeds screen) ---") try: with autopage.AutoPager() as out: for line in generate_lines(100): # Generate many lines to trigger the pager out.write(line) except Exception as e: print(f"An error occurred with autopage: {e}") print("Ensure a pager like 'less' is installed and available in your PATH.") print("--- End with autopage ---\n")
Debug
Known issues
gotchaDo not confuse `autopage` (for console output paging) with `autopager` (a different library for detecting web pagination links). They serve entirely different purposes and have different APIs.
fix
Ensure you are importing `from autopage import AutoPager` and not attempting to use web scraping functionality.
affects: All versions
gotchaThe default line buffering behavior of `AutoPager` matches the underlying stream's setting. If the output stream is not line-buffered (common when piping output to another command or file), you might experience delayed or incomplete output.
fix
Pass `line_buffering=True` to the `AutoPager` constructor (e.g., `with autopage.AutoPager(line_buffering=True) as out:`) to force line buffering.
affects: All versions
gotchaBy default, `AutoPager` leaves the latest displayed output on screen when the pager exits. If you prefer the terminal to clear and return to its state before the pager started (mimicking the default behavior of `less` when exited), you need to explicitly configure this.
fix
Pass `reset_on_exit=True` to the `AutoPager` constructor (e.g., `with autopage.AutoPager(reset_on_exit=True) as out:`).
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'autopage'
The 'autopage' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install autopage'.
ImportError: cannot import name 'AutoPager' from 'autopage'
The 'autopage' module is installed, but the 'AutoPager' class cannot be found, possibly due to an outdated version.
fix
Ensure you have the latest version of autopage installed: 'pip install --upgrade autopage'.
TypeError: __init__() got an unexpected keyword argument 'line_buffering'
An incorrect or unsupported keyword argument 'line_buffering' was passed to the 'AutoPager' class.
fix
Check the 'AutoPager' class documentation for the correct usage and supported arguments.
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '<path_to_site_packages>'
The user lacks the necessary permissions to install packages globally into the Python site-packages directory.
fix
Use 'pip install --user autopage' to install it in the user's home directory, or activate a virtual environment before installing.
AttributeError: module 'autopage' has no attribute 'write'
The user is attempting to call a 'write' method directly on the 'autopage' module, instead of on an 'AutoPager' instance obtained via the context manager.
fix
Use 'autopage.AutoPager()' as a context manager to get an output stream object, then call 'write' on that object:

import sys
import autopage

with autopage.AutoPager() as out:
    for line in sys.stdin:
        out.write(line)
Upgrade
Version history
0.6.0latest on PyPI · released Jan 30, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
10
Amazon
1
Resources
autopage — pip install autopage · libregistry