IPython - Enhanced Interactive Python

workaround for IPython + Emacs + WinXP

Reported by Jie Tang on 2008-10-28
Affects Status Importance Assigned to Milestone

Bug Description

Windows XP SP2
Emacs 22.3
ipython 0.9.1
python-mode.el 4.75

these are the steps I needed to get ipython working under emacs

First, to get ipython.el to work you need to edit the ipython.bat file and add a -i flag: i.e.
@C:\Python26\python.exe -i C:\Python26\scripts\ipython.py %*

next, something is broken with the way readline's _outputfile interacts with ipython under emacs/winXP.
I can get IPython working in emacs by modifying line 122 in genutils.py:

if sys.platform == 'win32' and readline.have_readline and (not 'EM_PARENT_PROCESS_ID' in os.environ):

EM_PARENT_PROCESS is a variable inserted into the environment when running processes under emacs.
This tells ipython not to use readline's _outputfile when running under emacs on windows.
NOTE: readline._outputfile is required for proper color display when running ipython from the command shell.

Finally, tab complete is broken under python 2.6 and using my version of ipython.el (may be fixed in the latest version)
In ipython.el, change the value of ipython-completion-command-string to

(defvar ipython-completion-command-string
  "print(';'.join(__IP.Completer.all_completions('%s'))) #PYTHON-MODE SILENT\n"
  "The string send to ipython to query for all possible completions")

This uses 2.6 print() function conventions, and should work with python 2.5 as well.

It also looks as if the history files generated by the emacs IPython and the command prompt ipython are incompatible; sometimes the emacs IPython will crash with a strange readline error. I've been deleting the _ipython/history file, which is somewhat annoying (but IPython can log sessions easily anyway).


Jie Tang (jietang86) on 2008-10-28
description: updated


Thank you - the solution is straithforward, seemless, and working.


Fernando Perez (fdo.perez) wrote :

As best I can tell, this is now fixed in trunk. If not, please let us know which parts are still a problem to apply a full patch upstream. Thanks!

Changed in ipython:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers