gpt4 book ai didi

Python 点击​​选项卡失败,出现 Python AttributeError : module 'readline' has no attribute 'redisplay'

转载 作者:行者123 更新时间:2023-12-02 20:11:21 25 4
gpt4 key购买 nike

在 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 行中的属性 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

关于Python 点击​​选项卡失败,出现 Python AttributeError : module 'readline' has no attribute 'redisplay' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56838545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com