{"id":14887,"library":"readline","title":"Python Readline (PyPI Package)","description":"The `readline` PyPI package (version 6.2.4.2) is a third-party distribution that aims to provide the functionality of the standard Python `readline` module, statically linked against the GNU readline library. It was primarily created for environments where the built-in `readline` module (part of the Python standard library) was unavailable or broken, particularly on older Python versions. It explicitly requires Python < 3.4 and is considered abandoned for modern Python versions. The standard `readline` module is built into CPython on Unix-like systems and typically does not require `pip install`.","status":"abandoned","version":"6.2.4.2","language":"en","source_language":"en","source_url":"http://github.com/ludwigschwardt/python-gnureadline","tags":["cli","interactive","shell","history","completion"],"install":[{"cmd":"pip install readline","lang":"bash","label":"Install (for Python < 3.4)"}],"dependencies":[],"imports":[{"symbol":"readline","correct":"import readline"}],"quickstart":{"code":"import readline\nimport os\n\n# Example completer function\ndef completer(text, state):\n    options = ['hello', 'world', 'exit', 'help']\n    matching_options = [cmd for cmd in options if cmd.startswith(text)]\n    if state < len(matching_options):\n        return matching_options[state]\n    else:\n        return None\n\n# Enable tab completion\nreadline.set_completer(completer)\nreadline.parse_and_bind('tab: complete')\n\n# Optional: Load/Save history\nhistfile = os.path.join(os.path.expanduser('~'), '.python_history')\ntry:\n    readline.read_history_file(histfile)\n    readline.set_history_length(1000)\nexcept FileNotFoundError:\n    pass # History file may not exist yet\nexcept Exception as e:\n    print(f\"Warning: Could not read history file: {e}\")\n\nprint(\"Type 'hello', 'world', 'exit', or 'help'. Press TAB for completion.\")\nwhile True:\n    try:\n        line = input(\">>> \")\n        if line == \"exit\":\n            break\n        print(f\"You typed: {line}\")\n    except EOFError:\n        print(\"\\nEOF encountered. Exiting.\")\n        break\n    except KeyboardInterrupt:\n        print(\"\\nKeyboardInterrupt. Exiting.\")\n        break\nfinally:\n    try:\n        # Ensure history is written if modifications were made\n        readline.write_history_file(histfile)\n    except Exception as e:\n        print(f\"Warning: Could not write history file: {e}\")","lang":"python","description":"This quickstart demonstrates basic tab completion and history management using the `readline` module's API. Note that the PyPI package `readline` provides this API, but is only compatible with Python < 3.4."},"warnings":[{"fix":"For Python 3.4+ on Unix-like systems, the standard `readline` module is built into CPython and does not require `pip install`. If you are on Windows, the built-in `readline` is unavailable; consider alternatives like `pyreadline3` or `prompt_toolkit`.","message":"This PyPI package ('readline' version 6.2.4.2) is incompatible with Python 3.4 and newer versions, explicitly requiring Python < 3.4. Attempting to install or use it on modern Python will fail.","severity":"breaking","affected_versions":"Python 3.4 and later"},{"fix":"Always check your Python version. If on Python 3.4+, rely on the standard library module (if on Unix) or an appropriate alternative (if on Windows/missing specific features). This PyPI package is not maintained for modern Python.","message":"Do not confuse this specific PyPI package (`readline`) with the standard library `readline` module. The standard module is an intrinsic part of CPython on Unix-like systems and typically does not need `pip install`. This PyPI package was a third-party attempt to provide that functionality for older Python versions or specific environments.","severity":"gotcha","affected_versions":"All Python versions"},{"fix":"Ensure you have the necessary system development headers and libraries for GNU readline installed before attempting `pip install readline`. For example, on Debian/Ubuntu: `sudo apt-get install libreadline-dev`. On Fedora/RHEL: `sudo dnf install readline-devel`.","message":"Installation of this `readline` PyPI package (even on Python < 3.4) can fail due to missing system-level GNU readline development libraries (e.g., `libreadline-dev` or `readline-devel`).","severity":"gotcha","affected_versions":"All supported Python versions (<3.4)"}],"env_vars":null,"search_vec":"'3.4':68 '6.2.4.2':10 'abandon':72 'aim':18 'broken':58 'built':45,82 'built-in':44 'cli':97 'complet':101 'consid':71 'cpython':84 'creat':39 'distribut':16 'environ':41 'explicit':65 'function':22 'gnu':33 'histori':100 'instal':96 'interact':98 'librari':35,54 'like':88 'link':30 'modern':74 'modul':28,48,80 'older':61 'packag':4,8 'part':49 'parti':15 'particular':59 'pip':95 'primarili':38 'provid':20 'pypi':3,7 'python':1,26,52,62,67,75 'readlin':2,6,27,34,47,79 'requir':66,94 'shell':99 'standard':25,53,78 'static':29 'system':89 'third':14 'third-parti':13 'typic':91 'unavail':56 'unix':87 'unix-lik':86 'version':9,63,76","created_at":"2026-04-20T18:44:07.771942+00:00","updated_at":"2026-04-20T18:44:07.771942+00:00","problems":[{"fix":"This package is for Python < 3.4. For modern Python (3.4+), use the built-in `readline` module (on Unix-like systems) or alternatives like `pyreadline3` / `prompt_toolkit`.","cause":"Attempting to install the `readline` PyPI package on Python 3.4 or newer.","error":"ERROR: Package 'readline' requires a different Python. Python 3.X.Y is not among the supported versions (<3.4)"},{"fix":"On Unix-like systems with Python 3.4+, ensure your Python installation includes readline support (it usually does). If on Windows, the built-in `readline` module is not available; consider `pyreadline3`. For Python < 3.4, ensure `pip install readline` was successful and system dependencies were met.","cause":"The `readline` module is not found. This can happen on Windows (where it's not built-in), if the system Python was compiled without readline support, or if the old PyPI package wasn't correctly installed for Python < 3.4.","error":"ImportError: No module named 'readline'"},{"fix":"Install the system-level GNU readline development libraries. For Debian/Ubuntu: `sudo apt-get install libreadline-dev`. For Fedora/RHEL: `sudo dnf install readline-devel`. Ensure your `LD_LIBRARY_PATH` (Linux) or `DYLD_LIBRARY_PATH` (macOS) is correctly configured if libraries are in non-standard locations.","cause":"The shared library for GNU readline (a system dependency) is missing or not found in the system's library paths. This is a common issue when installing C extensions that depend on system libraries.","error":"ImportError: libreadline.so.6: cannot open shared object file: No such file or directory"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.2.4.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":[],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-16","install_tag":null}}