python's readline module not available for windows?
Asked Answered
E

3

23

Granted I've been off PYTHON for two + years. I'm trying to get back into the swing, and I remember having command and variable completion available on windows a few years back. We were stuck in 2.6 as we had dependencies.

Today, I'm trying to import readline. I get this message from pip.

C:\Users\Joe>pip3 install readline Collecting readline Using cached https://files.pythonhosted.org/packages/f4/01/2cf081af8d880b44939a5f1b446551a7f8d59eae414277fd0c303757ff1b/readline-6.2.4.1.tar.gz Complete output from command python setup.py egg_info:error: this module is not meant to work on Windows

my version is:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. import readline Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'readline'

Eurythmics answered 3/7, 2018 at 14:47 Comment(0)
S
44

I have recently faced the same issue on Windows 10. readline is not available for Windows, however there is pyreadline3 (a continuation of the abandoned pyreadline package) which is for windows and you may try it.

Try to install pyreadline3 and use it instead of readline:

  • pip: pip install pyreadline3 or python -m pip install pyreadline
  • mamba: mamba install -c conda-forge pyreadline3
  • conda: conda install -c conda-forge pyreadline3

Then, in your python file do this:

from pyreadline3 import Readline
readline = Readline()

That way, you can use readline in Windows like in linux systems.

Sneck answered 22/8, 2018 at 10:15 Comment(6)
I have not been able to make this work with cmd2. I use cygwin and pycharm. Is there anything I should be checking?Blossom
No error, that I can see, I just don't see the prompt (I do with cmd on windows and cmd2 on linux) and <tab> <tab> doesn't autocomplete, and it works on linux.Blossom
@Lefteris Xris you are lifesaver! Confirming it works like a charm on Windows 10 cmd.exe python 3.8.3. I do not even need the two mentioned lines from pyreadline import Readline; readline = Readline()Honeysucker
The following NEW packages will be INSTALLED: pyreadline3 conda-forge/win-64::pyreadline3-3.4.1-py39hcbf5309_2 None python_abi conda-forge/win-64::python_abi-3.9-2_cp39 None Preparing transaction: done Verifying transaction: failed EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: c:\QGB\Anaconda3 Note: you may need to restart the kernel to use updated packages. ModuleNotFoundError: No module named 'pyreadline3'Salish
I did exactly this on Windows 10. But then >>> "readline.get_current_history_length()" returns 0. And >>>readline.write_history_file('C:\\folder1\\history1.txt') creates that file, but it's empty! Why is there no history? I was hoping it would export the command history (I guess that's what it does), there was plenty.Haggis
This tip worked perfectly for me on Windows. Worked like a charm, thanks.Archdeacon
R
2

Go to your CMD terminal and type

pip install pyreadline

with in few seconds it will be installed and you will be able to see message i.e. "Successfully installed pyreadline-"

then go back to your PYSPARK terminal and type again import readline it will import now without any error

Thanks

Rework answered 13/6, 2021 at 12:37 Comment(0)
D
2

I tried pyreadline after finding this question and had problems and eventually found that it is no longer supported.

What worked for me was installing pyreadline3 with:

pip install pyreadline3 
Drawplate answered 27/7, 2022 at 5:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.