Running Matplotlib or enthought.mayavi.mlab from a py-shell inside Emacs on Windows

1k Views Asked by At

I can run the following code fine from a regular cmd shell:

import matplotlib.pyplot as plt
fig = plt.figure()
plt.show()

It launches a Matplotlib window. However, running inside Emacs using shell or py-shell: the buffer just hangs and no window is launched. What's going on here and how can I fix it?

2

There are 2 best solutions below

0
On

I got it working with ipython.el.

I had to add modify python26\scripts\ipython.bat:

@"c:\Python26\python.exe" "-i" "c:\Python26\scripts\ipython.py" "-wthread" %*

Then in Emacs:

(setq ipython-command "c:/python26/scripts/ipython.bat")
(require 'ipython)
(py-shell)
0
On

After a tremendous amount of time and posting the bug on the matplotlib project page and the python-mode page I found out that supplying the arguments console --matplotlib in ipython.bat will do the trick with Matplotlib 1.3.1 and IPython 1.2.0.

This is what I have in my iphython.bat file:

@python.exe -i D:\devel\Python27\Scripts\ipython-script.py console --matplotlib %*