当我在Python解释器中按向上或向下箭头键时,会得到^ [[A或^ [[B而不是历史记录? [英] How come when I press the Up or Down Arrow keys in the Python interpreter I get ^[[A or ^[[B instead of history?

查看:191
本文介绍了当我在Python解释器中按向上或向下箭头键时,会得到^ [[A或^ [[B而不是历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
Python shell:箭头键在远程计算机上不起作用

我不知道为什么历史在Python 2.7.2解释器中不起作用.对于每个箭头键,我都得到了奇怪的字符组.在Terminal中不会发生这种情况.顺便说一句,我在Ubuntu 10.04上.这是这个地狱的屏幕截图:

I have no idea why history won't work in the Python 2.7.2 interpreter. I get strange character groups for each of the arrow keys. This doesn't happen in Terminal. BTW I am on Ubuntu 10.04. Here is a screen shot of this hell:

如何通过按向上和向下箭头键恢复获得命令历史记录的功能?

推荐答案

看起来好像您正在使用源代码构建.在您的发行版中安装libreadline-dev或同等软件包之后,您似乎需要重建Python.

It looks as if you're using a build from source. It looks like you'll need to rebuild Python after installing the libreadline-dev or equivalent package on your distribution.

更新:不需要特殊的构建步骤,只需运行make即可.最后有一些消息显示有关可选模块的信息,这些模块由于缺少依赖项而无法构建(除了readline之外,还有Tcl/Tkzlibgdbmopenssl依赖项,用于例如).

Update: There should be no special build steps needed, just running make should do. There are some messages printed at the end about optional modules which couldn't be built because of missing dependencies (in addition to readline, there are also Tcl/Tk, zlib, gdbm and openssl dependencies, for example).

如果由于某些原因无法运行make,请先尝试再次运行configure(如果make尚未为您运行).

If for some reason just running make doesn't work, try running configure again first (if make doesn't already run it for you).

这篇关于当我在Python解释器中按向上或向下箭头键时,会得到^ [[A或^ [[B而不是历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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