{"id":14833,"library":"pyreadline","title":"PyReadline","description":"PyReadline (version 2.1) is a Python implementation of GNU readline functionality, primarily designed for Windows, to provide enhanced command-line editing features like history and tab completion. The project's last release was in 2015, and it is largely unmaintained. For users on Python 3.8 and newer, the community-maintained fork `pyreadline3` is the recommended alternative for compatible functionality.","status":"maintenance","version":"2.1","language":"en","source_language":"en","source_url":"https://github.com/pyreadline/pyreadline","tags":["windows","readline","cli","console","interactive","unmaintained"],"install":[{"cmd":"pip install pyreadline","lang":"bash","label":"Install PyReadline"}],"dependencies":[{"reason":"Used for low-level interaction on Windows; included with Python 2.5+.","package":"ctypes","optional":false}],"imports":[{"note":"PyReadline, upon installation, creates a `readline.py` shim in site-packages to be imported as the standard `readline` module on Windows, allowing compatibility with modules like `rlcompleter`.","symbol":"readline","correct":"import readline"}],"quickstart":{"code":"import sys\n\n# pyreadline enhances the built-in input() function on Windows\n# if it's installed and correctly configured.\n# The primary use is passive: install it, and your Python REPL\n# and input() calls will have readline features.\n\nprint('Type something (with history and tab completion if pyreadline is active):')\ntry:\n    user_input = input('>>> ')\n    print(f'You typed: {user_input}')\n\n    # Example of a readline function (available via the shim)\n    # Requires pyreadline to be active and have bound these functions\n    import readline\n    # The following line might raise AttributeError if pyreadline isn't fully set up or patched\n    print(f'Current history length: {readline.get_current_history_length()}')\nexcept EOFError:\n    print('\\nExiting.')\nexcept AttributeError as e:\n    print(f'Readline attribute error: {e}. PyReadline might not be fully loaded or compatible with your Python version.')\nexcept Exception as e:\n    print(f'An unexpected error occurred: {e}')","lang":"python","description":"PyReadline primarily enhances the standard Python interactive prompt and the `input()` function on Windows. After installation, its features are generally active without explicit imports, though `import readline` will expose its API. This example demonstrates basic input and checks a `readline` function, noting potential compatibility issues with older versions."},"warnings":[{"fix":"Migrate to `pyreadline3` (`pip install pyreadline3`) for Python 3.8+ compatibility, or use an older Python version.","message":"PyReadline 2.1 is not compatible with Python versions 3.10 and later. Users attempting to use it on these versions will encounter errors.","severity":"breaking","affected_versions":"Python 3.10+"},{"fix":"For active development and compatibility with modern Python, use `pyreadline3`.","message":"The `pyreadline` project (version 2.1) has not been actively maintained since its last release in 2015. Many issues remain open, and it is considered stale.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Consider switching to `pyreadline3` which addresses this, or manually patch `Lib/site-packages/pyreadline/py3k_compat.py` to use `collections.abc.Callable`.","message":"Python 3.9+ changed `collections.Callable` to `collections.abc.Callable`. Older `pyreadline` versions may raise `AttributeError` or `TypeError` due to this change if not patched.","severity":"gotcha","affected_versions":"PyReadline 2.1 on Python 3.9+"},{"fix":"Only install `pyreadline` on Windows. On other operating systems, rely on the system's native readline implementation or use cross-platform alternatives like `prompt_toolkit`.","message":"PyReadline is specifically for Windows environments. On POSIX systems, Python typically uses GNU readline directly, and attempting to install or use `pyreadline` can lead to conflicts or errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install `pyreadline` (for older Python) or `pyreadline3` (for Python 3.8+) on Windows: `pip install pyreadline` or `pip install pyreadline3`.","cause":"Attempting to import the `readline` module on Windows without `pyreadline` or `pyreadline3` installed, as `readline` is a POSIX-specific standard library module.","error":"ModuleNotFoundError: No module named 'readline'"},{"fix":"Ensure `pyreadline` is fully installed and try restarting the Python environment. If the issue persists, consider `pyreadline3` which might have better compatibility, or review specific usage patterns for `readline` features.","cause":"This often occurs when `pyreadline` is installed but an application or a specific interaction attempts to call a `readline` function that `pyreadline` either doesn't implement or hasn't correctly exposed/bound. This can also be a symptom of general incompatibility or an incomplete setup.","error":"AttributeError: module 'readline' has no attribute 'redisplay'"},{"fix":"Upgrade to `pyreadline3`, which is designed for newer Python versions, or manually edit the `pyreadline` source to replace `collections.Callable` with `collections.abc.Callable`.","cause":"This error arises in Python 3.9 and later because `collections.Callable` was deprecated and then removed, replaced by `collections.abc.Callable`. PyReadline 2.1 uses the old path.","error":"TypeError: 'type' object is not subscriptable (related to collections.Callable)"}],"ecosystem":"pypi"}