在Windows上通过Emacs中的py-shell运行Matplotlib或enthought.mayavi.mlab
我可以在普通的命令行窗口里顺利运行以下代码:
import matplotlib.pyplot as plt
fig = plt.figure()
plt.show()
这段代码会打开一个Matplotlib窗口。不过,当我在Emacs里用shell或者py-shell运行时,界面就卡住了,根本没有窗口弹出来。这是怎么回事,我该怎么解决呢?
2 个回答
0
经过很长时间的努力,我在matplotlib项目页面和python-mode页面上发布了这个错误,最终发现只需要在ipython.bat文件中添加参数 console --matplotlib
就能解决问题,这个方法适用于Matplotlib 1.3.1和IPython 1.2.0。
这是我在我的 ipython.bat 文件里写的内容:
@python.exe -i D:\devel\Python27\Scripts\ipython-script.py console --matplotlib %*
0
我用 ipython.el 让它工作起来了。
我需要修改 python26\scripts\ipython.bat 文件:
@"c:\Python26\python.exe" "-i" "c:\Python26\scripts\ipython.py" "-wthread" %*
然后在 Emacs 中:
(setq ipython-command "c:/python26/scripts/ipython.bat")
(require 'ipython)
(py-shell)