程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

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

发布于2019-12-17 09:26     阅读(2845)     评论(0)     点赞(8)     收藏(0)


在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


所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/177188/2791ce1d0577fc0afd37/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

8 0
收藏该文
已收藏

评论内容:(最多支持255个字符)