Loading...
Loading...
ModuleNotFoundError: No module named 'readline'The `readline` module provides text-completion and history capabilities for Python's interactive prompts. However, `readline` is a Unix/Linux-only C library and does not exist on Windows. When you try to run a script containing `import readline` on Windows, it crashes.
On Windows, you can install `pyreadline3`, which acts as a drop-in polyfill replacement for `readline`.
pip install pyreadline3If you are the developer writing the script, use a try/except block to gracefully degrade or load the alternative.
try:
import readline
except ImportError:
try:
import pyreadline3 as readline
except ImportError:
pass # Optional: prompt user to install pyreadline3