在 python 终端中导航

发布于 2024-08-08 23:27:16 字数 698 浏览 1 评论 0原文

我想要在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

呆橘 2024-08-15 23:27:16

听起来您的自定义构建不包括 readline。应该是一个简单的配置更改和重建,请检查 此处了解更多信息。

Sounds like your custom build didn't include readline. Should be a simple config change and rebuild, check here for more info.

不爱素颜 2024-08-15 23:27:16

此处安装 GNU readline 库,并重建 python 修复了问题。

Installing the GNU readline library from here, and rebuilding python fixes the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文