Pythons控制台模块使无法键入Tab键 [英] Pythons Console Module has made it impossible to type the tab key

查看:128
本文介绍了Pythons控制台模块使无法键入Tab键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不久前,我开始在自己的程序中使用它。从那时起,每当我在运行python的控制台(cmd.exe实例)上键入tab键时,都会收到readline内部错误。完整的追溯如下(请注意,我没有在此上下文中导入cmd模块,甚至没有使用该脚本导入脚本。我只是启动了python,按下了tab键,并声明了一个例外):

I started using it on one of my programs a while back. Ever since, whenever I type the tab key on a console (cmd.exe instance) with python running, I get a readline internal error. Full traceback is as follows (note I haven't imported the cmd module in this context or even imported a script using it. I've simply started python, pressed tab and voila an exception):

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

在您问之前,我将python安装到目录 C:\SP_CI_PROGRAMS\Languages\Python6.13.6.1。可通过path变量进行访问。同样,我设计的任何脚本(放置在目录中)也可以从path变量访问(包括使用python cmd模块的脚本)。

Before u ask, I installed python to the directory "C:\SP_CI_PROGRAMS\Languages\Python\3.6.1". It's accessible from the path variable. Also any scripts I design I place in a directory u can also access from the path variable (including one using the cmd module for python).

迫切关注,特别是因为我只能键入4个空格,但是使用制表符已经成为我特别习惯的事情,第二次键入Tab键时,我在上一个块中写的任何内容都会立即作为回溯而丢失打印。

This may not seem like a pressing concern, especially seeing as I can just type 4 spaces instead, however using tabs is something I've become especially accustomed to and the second I type the tab key, anything I've written in a previous block is immediately lost as the traceback is printed. Please, can someone tell me how to fix this.

编辑:这仅在python解释器中。在正在运行的程序中键入选项卡或其他内容不会造成任何问题。

This is only within the python interpreter. Typing tab within a running program or something else doesn't pose any problems.

推荐答案

似乎是Windows计算机的持续问题如 Github 所示。一种解决方法似乎是卸载 pyreadline 软件包。

Seems to be a continuing issue for Windows machines as seen on Github. A workaround seems to be uninstalling the pyreadline package.

这篇关于Pythons控制台模块使无法键入Tab键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆