bph bph - 3 years ago 274
Bash Question

Running Python inside Emacs on Windows

I've just installed Python 2.7 on windows along with IPython.

I'm used to running IPython from within Emacs on Linux, e.g.

M-x shell

Then type '
' at the prompt.

This works fine under Linux, but under Windows it hangs after printing the IPython banner text, i.e. it looks like it's working, but then you never get an IPython prompt.

I can load IPython (and Python) under Windows no problem from a standard cmd terminal, just not from within Emacs.

Anyone else experienced or hopefully solved this issue?

I get the same problem when trying to start plain old Python as well.

Answer Source

In Windows it won't work as easily, and it's very annoying. First, make sure you have installed pyreadline.

Next, I have got it working with a bat file that is in my system path containing:

@python.exe -i C:\devel\Python\2.7-bin\Scripts\ipython.py  --pylab %*

Next get python-mode.el and delete ipython.el. The latter is deprecated and python-mode includes its functionality.

Change the path of the ipython.py file accordingly and save it. Now in your Emacs do the following in your init.el file.

 '(py-shell-name "ipython.bat"))

Alternatively, to achieve the last step, do C-h v <RET> py-shell-name and customize it and change it to ipython.bat or the full path of your ipython.bat if the scripts directory is not in your system path. Save for future sessions.

That should get your IPython shell working. There is one more caveat if you want multiple interactive matplotlib figures without hanging your IPython console. The only way I could get around this issue was to use IPython 0.10 instead of the current version.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download