Python hitting tab fails with Python AttributeError: module 'readline' has no attribute 'redisplay'
Python hitting tab fails with Python AttributeError: module 'readline' has no attribute 'redisplay'
在 Windows 上使用 Python 3.7.3 (Anaconda),点击选项卡会导致以下回溯:
Readline internal error
Traceback (most recent call last):
File "C:\...\anaconda3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
res = ensure_str(readline_hook(prompt))
File "C:\...\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
self._readline_from_keyboard()
File "C:\...\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
if self._readline_from_keyboard_poll():
File "C:\...\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
result = self.mode.process_keyevent(event.keyinfo)
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
r = self.process_keyevent_queue[-1](keyinfo)
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
r = dispatch_func(keyinfo)
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
completions = self._get_completions()
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
r = self.completer(ensure_unicode(text), i)
File "C:\...\anaconda3\lib\rlcompleter.py", line 80, in complete
readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'
环境详情:
- Windows 10 个 64 位
- Python 3.7.3、Anaconda 分布
- pyreadline == 2.1
- Tab 键在 IPython
中工作正常
我知道 pyreadline 可能会导致此问题。 Tab not working in python 3.6, working in 3.5, 3.6 32 bit version on Windows 建议卸载 pyreadline。但是,当我尝试 pip uninstall pyreadline
时出现此错误:
Cannot uninstall 'pyreadline'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
尝试这个也没有帮助:Unable to install 'pyreadline' using pip on Windows
Anaconda 模块 readline 与标准 Python readline 不同,后者具有重新显示方法。我发现使这项工作可行的解决方法是禁用自动完成功能。要存档,您需要在文件 rlmain.py 行 58.[=13 中将属性 disable_readline 设置为 True =]
..\Anaconda3\Lib\site-packages\pyreadline\rlmain.py
class BaseReadline(object):
def __init__(self):
self.allow_ctrl_c = False
self.ctrl_c_tap_time_interval = 0.3
self.debug = False
self.bell_style = 'none'
self.mark = -1
self.console=MockConsole()
self.disable_readline = True # Old value: False
在 Windows 上使用 Python 3.7.3 (Anaconda),点击选项卡会导致以下回溯:
Readline internal error
Traceback (most recent call last):
File "C:\...\anaconda3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
res = ensure_str(readline_hook(prompt))
File "C:\...\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
self._readline_from_keyboard()
File "C:\...\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
if self._readline_from_keyboard_poll():
File "C:\...\anaconda3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
result = self.mode.process_keyevent(event.keyinfo)
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
r = self.process_keyevent_queue[-1](keyinfo)
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
r = dispatch_func(keyinfo)
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
completions = self._get_completions()
File "C:\...\anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
r = self.completer(ensure_unicode(text), i)
File "C:\...\anaconda3\lib\rlcompleter.py", line 80, in complete
readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'
环境详情:
- Windows 10 个 64 位
- Python 3.7.3、Anaconda 分布
- pyreadline == 2.1
- Tab 键在 IPython 中工作正常
我知道 pyreadline 可能会导致此问题。 Tab not working in python 3.6, working in 3.5, 3.6 32 bit version on Windows 建议卸载 pyreadline。但是,当我尝试 pip uninstall pyreadline
时出现此错误:
Cannot uninstall 'pyreadline'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
尝试这个也没有帮助:Unable to install 'pyreadline' using pip on Windows
Anaconda 模块 readline 与标准 Python readline 不同,后者具有重新显示方法。我发现使这项工作可行的解决方法是禁用自动完成功能。要存档,您需要在文件 rlmain.py 行 58.[=13 中将属性 disable_readline 设置为 True =]
..\Anaconda3\Lib\site-packages\pyreadline\rlmain.py
class BaseReadline(object):
def __init__(self):
self.allow_ctrl_c = False
self.ctrl_c_tap_time_interval = 0.3
self.debug = False
self.bell_style = 'none'
self.mark = -1
self.console=MockConsole()
self.disable_readline = True # Old value: False