1

*** Update: the problem is with running python inside emacs on windows. ipython and elpy are off the hook. From a plain DOS prompt: python; from pylab import *; figure(1); show() works. If I start (windows-native) emacs with emacs -Q (turn off all customizations, so no elpy etc), then Alt-x run-python, I get a python (not ipython) prompt within emacs. from pylab import *; figure(1); show() doesn't work - no figure window appears, and I don't get back a python prompt.

*** Original post: Very annoying problem, have talked to elpy and matplotlib people but we are stumped.

Goal: run ipython as a process within emacs, and get matplotlib plots to work. Regarding OSes, "linux is nice but I prefer emacs".

My setup: Windows 7, Python packages thru Anaconda (python 3.6.2, ipython 6.1.0, matplotlib 2.0.2), emacs - 25.3 official GNU windows build (NOT cygwin, though I use the cygwin tools like grep, diff, etc in emacs), elpy emacs package for working with python.

Elpy has support for ipython. As long as I don't make a plot, this works fine - I can edit python files in emacs, send them to an ipython session, work in it. Also, outside of emacs if I just run ipython from a DOS prompt, matplotlib figures work fine (also work fine from Spyder).

I have made sure to revert to a plain vanilla setup - no config files, TkAgg matplotlib backend (those Qt gave similar but slightly different problems).

So: I start ipython within emacs, and do 'pylab'.

** plt.ion(), figure(1): window appears, with buttons on bottom. ipython prompt works. If I interact with the figure window, I get “not responding” in title, and MS Windows’ spinning shell. If I close the figure window by clicking on the X in upper right, windows says “app not responding.” Dialog box w/ End Process or Cancel. End process kills figure and ipython session.

** If instead plt.ioff(), figure(1): plot(1,1) show() I get a figure window with a plot, but if I interact with it I get “not responding.” ipython prompt seems fine. I can close window from prompt close(1) and ipython fine.

Tom Caswell (matplotlib) thinks it's an issue with the input hook. I don't know how to work with this, but maybe it's enough of a clue.

I'd think the 'Venn diagram' for people using python for science + emacs + Windows wouldn't be that small.

4

1 回答 1

0

以下已经工作了几个月:使用 jupyter 控制台而不是 ipython。Jupyter 最终只运行 ipython,但它启动 ipython 或与 Windows 或 emacs 接口的方式使 matplotlib 工作。我不太明白为什么。虽然它给了我很好的结果。

我也停止使用 elpy。我的 .emacs 有以下内容:

(setq python-shell-interpreter "jupyter"
  python-shell-interpreter-args "console --simple-prompt")
(setq python-shell-completion-native-enable nil)

最后一行可能与 matplotlib 数字无关。

于 2018-08-10T18:14:19.330 回答