user650654
user650654

Reputation: 6128

iPython warning in Emacs: your terminal doesn't support cursor position requests (CPR)

How do I get ipython working correctly under emacs?

Following the ipython docs recommendation, I have enabled ipython:

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

I get the following warning when I start the ipython server.

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).

The "[In]" prompts do not print at all. And also when code is sent from another buffer (e.g. through python-shell-send-buffer). Here is a sample screen dump (I'm guessing that the i 8 i 8 is from the prompt not being properly displayed):

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

hello world

Interactively, the "[Out]" prompts sometimes display and sometimes not:

print('hello world')

hello world

4

Out[3]: 4

Emacs I'm running on macos:

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.

Upvotes: 3

Views: 11339

Answers (3)

jacobra
jacobra

Reputation: 2142

I encountered this issue while running my python script inside a Docker container. I had forgotten to include the -i flag on docker run. After adding the flag, this warning cleared and ipdb behaved as expected.

Upvotes: 1

J. Chang
J. Chang

Reputation: 105

I downgrade my ipython or ipdb version and the problem solved... I dont know why.

I met this problem in my virtual env, and the ipython version is 7.16.1 But when I deactivate the virtual env, the problem didn't happen and this time the version of ipython is 7.7.0. So I degrade the version in my virtual env.

Upvotes: 2

jpkotta
jpkotta

Reputation: 9417

(setq python-shell-interpreter-args "--simple-prompt -i")

ipython assumes you have a "normal" terminal, but in Emacs it runs under a "dumb" terminal. Really, ipython should be able to know this through the TERM environment variable. Looks like there was some recent effort on this: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/390. Hopefully it will Just Work in a future release.

Upvotes: 5

Related Questions