4

I am using the newest emacs25.1.1 with the newest archlinux.

However, when I edit a python scripts and send it to the Inferior ipython by using Ctrl-Enter, the inferior Python show me a ugly messy code termial indicater like:

Python 3.5.2 (default, Nov  7 2016, 11:31:36) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

[JIn [1]: import numpy as np[26D
[J
[6n[JIn [2]: [8D[8C[8D[J[6n[JIn [2]: [8D[8C

When press Enter in this Inferior python, it shows:

error in process filter: Args out of range: "
^[[6n^[[0m^[[0m^[[J^[[0;38;5;28mIn [^[[0;38;5;28m: ^[[8D^[[8C[[0m^[[0m", 128

I change the emacs locale from:

LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

To:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

with the command $"export LANGUAGE="en_US:en" && emacs"$, no help to resolve the messy code.

I also try python-mode.et or elpy package in emacs, all show the same messy terminal code.

Further,python2.7 also tried, no work:

Python 2.7.12 (default, Nov  7 2016, 11:55:55) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

[JIn [1]: import numpy as np[26D
[J
[6n[JIn [2]: [8D[8C[8D[J[6n[JIn [2]: [8D[8C

Is the newest ipython problem?

At last the message in emacs paste here:

error in process filter: ansi-color-filter-apply: Args out of range: "Python 3.5.2 (default, Nov  7 2016, 11:31:36) 
Type \"copyright\", \"credits\" or \"license\" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

[6n[0m
[0m[J
[0m", 408
error in process filter: Args out of range: "Python 3.5.2 (default, Nov  7 2016, 11:31:36) 
Type \"copyright\", \"credits\" or \"license\" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

[6n[0m
[0m[J
[0m", 408
error in process filter: ansi-color-filter-apply: Args out of range: "[0m[0m[J[0;38;5;28mIn [[0;38;5;10;1m1[0;38;5;28m]: [0;38;5;28;1mimport[0m [0;38;5;32;1mnumpy[0m [0;38;5;28;1mas[0m [0;38;5;32;1mnp[26D[0m
[J[0m", 177
error in process filter: Args out of range: "[0m[0m[J[0;38;5;28mIn [[0;38;5;10;1m1[0;38;5;28m]: [0;38;5;28;1mimport[0m [0;38;5;32;1mnumpy[0m [0;38;5;28;1mas[0m [0;38;5;32;1mnp[26D[0m
[J[0m", 177
error in process sentinel: elpy-rpc--default-error-callback: peculiar error: "exited abnormally with code 1"
error in process sentinel: peculiar error: "exited abnormally with code 1"
error in process filter: ansi-color-filter-apply: Args out of range: #("[JIn [1]: import numpy as np[26D
[J


[6n[0m[0m[J[0;38;5;28mIn [[0;38;5;10;1m2[0;38;5;28m]: [8D[8C[0m[0m[8D[J[0m[6n[0m[0m[J[0;38;5;28mIn [[0;38;5;10;1m2[0;38;5;28m]: [8D[8C[0m" 0 38 (fontified nil) 38 39 (fontified nil)), 283
error in process filter: Args out of range: #("[JIn [1]: import numpy as np[26D
[J


[6n[0m[0m[J[0;38;5;28mIn [[0;38;5;10;1m2[0;38;5;28m]: [8D[8C[0m[0m[8D[J[0m[6n[0m[0m[J[0;38;5;28mIn [[0;38;5;10;1m2[0;38;5;28m]: [8D[8C[0m" 0 38 (fontified nil) 38 39 (fontified nil)), 283
cwind
  • 369
  • 1
  • 7

2 Answers2

5

I've used recomendation from https://github.com/jorgenschaefer/elpy/issues/992#issuecomment-249165923. In short - add the following code: (setenv "IPY_TEST_SIMPLE_PROMPT" "1") into emacs configuration file.

legoscia
  • 39,593
  • 22
  • 116
  • 167
opsa aspo
  • 51
  • 1
  • 3
0

From the output and error message, it would appear that for some reason, your setup is not handling the ansi escape sequences used by ipython. Assumiing you are using pythong-mode, ensure you have the following

(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "-i")

To eliminate other possible settings in your init file, I would comment out everything except the above and try again. If it works, then there is something in your setup which is messing with the ability of emacs to handle the ansi control sequences being output by ipython. If it still doesn't work, then you may need to log a bug report.

there are also a few things you can do to work around the issue.

  1. Try adding the --no-color-info switch to ipython. This will reduce the number of control characters ipython outputs, which my limit the problem.
  2. Consider using just python rather than ipython as the inferior process. The problem you are seeing is due to ipython using ansi control characters to provide a nicer shell. However, emacs is really your shell and you may be better off letting emacs take care of the interface and just use a simpler inferior shell
  3. The Emacs Wiki has a fairly detailed description on how to setup a powerful python development environment. Using a simple ipython/python inferior process is the most basic approach. You may do better putting in time with some of the other packages to get a more complete development environment.
Tim X
  • 4,158
  • 1
  • 20
  • 26
  • I think this is a bug for emacs25? I comment all the python setup in .emacs, then M-x py-send-region-ipython, it occur to the same problem. Add what your suggests, the problem is still there. Besides, python inferior is works well. – cwind Dec 31 '16 at 06:05
  • It may not be just a python specific config. Make sure you have commented out ALL configurations except the ipython specific ones and then retest. Emacs 25.1 is vary new, so a bug is possible. However, it is also used by a lot of python developers, so the odds you have found a bug is small compared to an error in your config file. To log a bug report, you need to show a minimum config so that the emacs devs can reproduce it. Note the comment on your post which indicates at least one ofther emacs 25.1 user could not reproduce your problem, which indicates local config issue – Tim X Dec 31 '16 at 07:20
  • @cwind Please load python-mode.el from emacs -Q and send us a bug-report, should it still occur. – Andreas Röhler Dec 31 '16 at 10:17
  • Thanks for your reminder, The only init config of python `(setq python-shell-interpreter "ipython" python-shell-interpreter-args "-i")` was added. But the problems is also happened.. So it mostly attribute to the new ipython and new emacs works not very well – cwind Jan 01 '17 at 03:02