Python命中选项卡失败并显示Python AttributeError:模块“ readline”没有属性“ redisplay”

Python命中选项卡失败并显示Python AttributeError:模块“ readline”没有属性“ 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在python 3.6上不起作用,在Windows上的 3.5,3.6 32位版本上工作,建议卸载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.

尝试此操作也无济于事:无法在Windows上使用pip安装“ pyreadline”

解决方案

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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值