Subject: bug#17542: python.el and ipython

From: Federico Beffa <[email-masked]>
Date: Wed, 21 May 2014 15:22:41 +0200

I'm trying to set up the python-mode (python.el) to use ipython as the
interactive shell. I've added the folloging lines in my .emacs file:

(require 'python)
(setq
 python-shell-interpreter "C:/Python27/python.exe"
 python-shell-interpreter-args
   "-i C:/Python27/Scripts/ipython-script.py console --matplotlib=tk"
 ;; python-shell-interpreter-args
 ;;   "-i C:/Python27/Scripts/ipython-script.py console --matplotlib=qt"
 python-shell-prompt-regexp "In \\[[0-9]+\\]: "
 python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
 python-shell-completion-setup-code
   "from IPython.core.completerlib import module_completion"
 python-shell-completion-module-string-code
   "';'.join(module_completion('''%s'''))\n"
 python-shell-completion-string-code
   "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")

My python installation is Python(x,y) 2.7.6 (the most recent
distribution).

I'm having INTERMITTENT problems starting a python shell process (either
with run-python or with C-c C-z in a python program source file) while
specifying to use the qt backend for matplotlib. Sometimes everything
just runs smoothly, but often the new python shell window appears as
follows:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 1.2.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.

In [1]:
In [2]:

and freezes: no response to whatever command. I just have to kill the
buffer. Note that when the process starts correctly I get 4 input
prompts (In [1]:\n In [2]:\n In [3]:\n In [4]:\n).

The problem happens starting emacs with -Q as well.

This does not happen if I use tk as the backend for matplotlib and
everything works fine. Everything works fine outside of emacs as well
(in a console) with both matplotlib backends.

I've checked and confirmed the problem on two different machines running
Windows 7 (one with the Ultimate and the other with the Enterprise variant).

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
c:/Program Files (x86)/emacs-24.3/etc/DEBUG.

In GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601)
 of 2013-03-17 on MARVIN
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --with-gcc (4.7) --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include
 -ID:/devel/emacs/libs/libiconv-1.13.1-1-dev/include
 -ID:/devel/emacs/libs/libxml2-2.7.8/include/libxml2'

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252
  default enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  jedi-mode: t
  auto-complete-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-c C-z <return> y C-x o C-x C-f <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> c : / p r o <tab> SPC f <tab> SPC <tab>
e m <tab> 3 <tab> s i <tab> s i <tab> d <tab> f <tab>
<return> <C-end> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> C-SPC <down>
<down> M-x c o m m <tab> e <tab> r e <tab> <return>
<up> <up> <up> <up> C-SPC <down> <down> M-x u n c o
m <tab> <return> C-x C-s C-x k <return> M-x r e <tab>
p <tab> o <tab> r <tab> <return>

Recent messages:
Sent python-shell-completion-setup-code
Sent python-ffap-setup-code
Sent python-eldoc-setup-code
Mark set [2 times]
Making completion list...
Mark set
Saving file c:/Program Files
(x86)/emacs-24.3/site-lisp/site-start.d/fbe.el...
Cannot write backup file; backing up in ~\.emacs.d\%backup%~
Wrote c:/Program Files (x86)/emacs-24.3/site-lisp/site-start.d/fbe.el
Making completion list... [3 times]

Load-path shadows:
None found.

Features:
(shadow sort flyspell ispell mail-extr emacsbug message format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mail-utils help-mode compile network-stream auth-source eieio byte-opt
bytecomp byte-compile cconv gnus-util mm-util mail-prsvr password-cache
starttls tls warnings advice advice-preload jedi help-fns easy-mmode
python-environment auto-complete cl-macs gv popup epc ctable edmacro
kmacro concurrent deferred cl cl-lib server preview-latex python rx
easymenu comint ring ansi-color jedi-autoloads auto-complete-autoloads
epc-autoloads ctable-autoloads concurrent-autoloads popup-autoloads
finder-inf python-environment-autoloads deferred-autoloads package
tex-site auto-loads time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp w32-common-fns disp-table w32-win
w32-vars tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
w32 multi-tty emacs)