在 python 终端中导航
我想要在我的 Mac 上有一个 64 位 python 解释器,所以我必须从源代码重建。然而,使用我自己的自定义构建解释器,当我尝试从 shell 内部运行解释器进行导航时,我遇到了问题。在 bash shell 中输入 python 会产生熟悉的结果:
Python 2.6.3 (r263:75183, Oct 23 2009, 14:23:25)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
但是,当我尝试使用左箭头和右箭头导航时,我得到奇怪的字符:
Python 2.6.3 (r263:75183, Oct 23 2009, 14:23:25)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^[[A^[[A^[[A^[[D^[[C^[[C^[[A^[[B^[[D^[[C
这在 Apple 的默认解释器中不会发生。
是什么原因造成的?我该如何修复它?
I want a 64-bit python interpreter on my Mac so I had to rebuild from source. However, with my own custom build interpreter I run into issues when I try to navigate when I run the interpreter from inside a shell. Typing python into the bash shell results in the familiar:
Python 2.6.3 (r263:75183, Oct 23 2009, 14:23:25)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
However, when I try to navigate with left-arrow and right-arrow, I get weird characters:
Python 2.6.3 (r263:75183, Oct 23 2009, 14:23:25)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^[[A^[[A^[[A^[[D^[[C^[[C^[[A^[[B^[[D^[[C
This does not occur in Apple's default interpreter.
What is causing this? How can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您的自定义构建不包括 readline。应该是一个简单的配置更改和重建,请检查 此处了解更多信息。
Sounds like your custom build didn't include readline. Should be a simple config change and rebuild, check here for more info.
从此处安装 GNU readline 库,并重建 python 修复了问题。
Installing the GNU readline library from here, and rebuilding python fixes the problem.