Skip to content

pyreadline workaround for... don't remember what #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stonebig opened this issue Jun 19, 2017 · 13 comments
Closed

pyreadline workaround for... don't remember what #544

stonebig opened this issue Jun 19, 2017 · 13 comments

Comments

@stonebig
Copy link
Contributor

for cvxpy ?

https://github.com/ankostis/pyreadline/tree/redisplay

@stonebig
Copy link
Contributor Author

done/ready, if I need it somewhere

@ankostis
Copy link

Just to remind that without that branch (actually PR pyreadline/pyreadline#56), pressing [Tab] in python interpreter raises the error described in pyreadline/pyreadline#49:

  File "C:\Users\dbrattli\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
    r = self.completer(ensure_unicode(text), i)
  File "C:\Users\dbrattli\AppData\Local\Programs\Python\Python35-32\lib\rlcompleter.py", line 80, in complete
    readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'

And readline gets installed because of dill (uqfoundation/dill#181).

@stonebig
Copy link
Contributor Author

in theory @ankostis , I should have picked your branch in current beta

@ankostis
Copy link

...but in practice?

@stonebig
Copy link
Contributor Author

... in practice, I didn't have much time last month to check anything but new spyder features and jupyterlab-0.26 incompatiblities. maybe someone can confirm cvxpy works well on latest beta.

@ankostis
Copy link

The important thing is for the next WinPython to use this branch, or else python interpreter is broken(!), as explained in the issues linked above.

@stonebig
Copy link
Contributor Author

how I get pyreadline in the interpreter loop is a bit obscure to me, please explain me step by step, so I will check if it blows up

@ankostis
Copy link

I have no knowledge of pyreadline - I produced the fix based on other PRs and some superificial study to fix the remaining bugs.

To reproduce the problems, just pip install pyreadline and then lanuch python; you should received:

@cygwin:~$pip install pyreadline
Collecting pyreadline
Installing collected packages: pyreadline
Successfully installed pyreadline-2.1
@cygwin:~$python
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site.py", line 418, in register_readline
    readline.read_history_file(history)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 2581: character maps to <undefined>
>>>

Pressing [Tab] you will receive:

>>> Readline internal error
Traceback (most recent call last):
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
    res = ensure_str(readline_hook(prompt))
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
    self._readline_from_keyboard()
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
    if self._readline_from_keyboard_poll():
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
    result = self.mode.process_keyevent(event.keyinfo)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
    r = self.process_keyevent_queue[-1](keyinfo)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
    r = dispatch_func(keyinfo)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
    completions = self._get_completions()
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
    r = self.completer(ensure_unicode(text), i)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\rlcompleter.py", line 80, in complete
    readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'
>>>

@TylerGubala
Copy link

TylerGubala commented Feb 2, 2018

I continue to have this issue...? Possibly something that needs to be looked into again?

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32

>>> Readline internal error
Traceback (most recent call last):
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
    res = ensure_str(readline_hook(prompt))
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
    self._readline_from_keyboard()
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
    if self._readline_from_keyboard_poll():
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
    result = self.mode.process_keyevent(event.keyinfo)
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
    r = self.process_keyevent_queue[-1](keyinfo)
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
    r = dispatch_func(keyinfo)
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
    completions = self._get_completions()
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
    r = self.completer(ensure_unicode(text), i)
  File "C:\Users\TGubs\AppData\Local\Programs\Python\Python36\lib\rlcompleter.py", line 80, in complete
    readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'

@Zaksh
Copy link

Zaksh commented Feb 16, 2018

I am also having the same issue on

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32.

When I press TAB I get the following error

>>> Readline internal error
Traceback (most recent call last):
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
    res = ensure_str(readline_hook(prompt))
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
    self._readline_from_keyboard()
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
    if self._readline_from_keyboard_poll():
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
    result = self.mode.process_keyevent(event.keyinfo)
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
    r = self.process_keyevent_queue[-1](keyinfo)
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
    r = dispatch_func(keyinfo)
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
    completions = self._get_completions()
  File "C:\Python\Python36-32\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
    r = self.completer(ensure_unicode(text), i)
  File "C:\Python\Python36-32\lib\rlcompleter.py", line 80, in complete
    readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'

@stonebig stonebig reopened this Feb 16, 2018
@TylerGubala
Copy link

TylerGubala commented Feb 16, 2018

I was able to remedy this by uninstalling Pyreadline which was temporarily satisfactory for me.

I tried installing a new version of python and it still gave me the same error.

I think pyreadline's presence in site-packages was the issue

@stonebig
Copy link
Contributor Author

so I may remove it. it's the last legacy of binary packages, and it's more an annoyance than anything.

@deduble
Copy link

deduble commented Apr 2, 2018

I have no idea why was this happening? Anyone has an idea was main python was creating these errors and not ipython kernal, with pyreadline and why did I suddenly start to have it? Again removing pyreadline helped me but still...

@stonebig stonebig closed this as completed May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants