【问题标题】:iPython warning in Emacs: your terminal doesn't support cursor position requests (CPR)Emacs 中的 iPython 警告:您的终端不支持光标位置请求 (CPR)
【发布时间】:2020-03-04 20:43:41
【问题描述】:

如何让 ipython 在 emacs 下正常工作?

按照ipython docs recommendation,我启用了ipython:

(require 'python)
(setq python-shell-interpreter "ipython")

我在启动 ipython 服务器时收到以下警告。

Python 3.7.4 (default, Jul  9 2019, 18:15:00) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.

WARNING: your terminal doesn't support cursor position requests (CPR).

[In]”提示根本不打印。当代码从另一个缓冲区发送时(例如通过python-shell-send-buffer)。这是一个示例屏幕转储(我猜i 8 i 8 来自未正确显示的提示):

WARNING: your terminal doesn't support cursor position requests (CPR).
i
8
i
8

hello world

以交互方式,“[Out]”提示有时显示有时不显示:

print('hello world')

hello world

4

Out[3]: 4

我在 macos 上运行的 Emacs:

This is GNU Emacs 26.3 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511))
 of 2019-09-02
Copyright (C) 2019 Free Software Foundation, Inc.

【问题讨论】:

    标签: emacs ipython


    【解决方案1】:
    (setq python-shell-interpreter-args "--simple-prompt -i")
    

    ipython 假设你有一个“普通”终端,但在 Emacs 中它运行在 "dumb" terminal 下。真的,ipython 应该可以通过TERM 环境变量知道这一点。看起来最近有一些努力:https://github.com/prompt-toolkit/python-prompt-toolkit/issues/390。希望它会在未来的版本中正常工作。

    【讨论】:

      【解决方案2】:

      我降级了我的 ipython 或 ipdb 版本,问题解决了…… 我不知道为什么。

      我在虚拟环境中遇到了这个问题,ipython版本是7.16.1 但是当我停用虚拟环境时,问题并没有发生,这次 ipython 的版本是 7.7.0。 所以我在我的虚拟环境中降级了版本。

      【讨论】:

      • 更具体地说,还是会出现警告,但是在交互式ipython中输入输出正常。
      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2021-08-26
      • 2013-04-12
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多