【发布时间】:2013-06-14 20:51:50
【问题描述】:
我之前以为是 IPython 的问题,但今天我再次测试,这是我所做的:
- 在cmd窗口中运行
emacs -Q - 打开一个 .py 文件
-
M-x,然后运行 python-shell-switch-to-shell、RET和RET。然后我准备好了 Python shell - 然后我输入以下代码:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib.pyplot as plt >>> plt.ion() >>> plt.plot([1,2,3]) [<matplotlib.lines.Line2D object at 0x03068610>] >>>
实际上在这之后,没有显示任何图形,并且外壳被冻结,例如,当我输入时:
>>> print("hello")
什么都没发生...我没有测试过其他绘图工具,但 matplotlib。我不知道这是否是一个错误。我已经搜索了一段时间,在这里和谷歌,但没有运气。我的系统是:Emacs 24.3 32 bit for Windows,在 Windows 7 下。如果其他人可以复制与此处相同的问题,我将报告此错误。
我使用 IPython 作为 Python shell:
C:/Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab
然后,我输入figure(); plot([1,2,3]),不出所料,图形弹出并冻结。然后我做了:C-c C-d,它运行comint-send-eof,这个数字实际上得到了更新!但我的 IPython shell 会话也因以下消息而终止:
In [6]:
Do you really want to exit ([y]/n)?
Traceback (most recent call last):
File "C:/Python27/Scripts/ipython-script.py", line 9, in <module>
load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
SystemExit
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
这里有什么有用的线索吗?!
【问题讨论】:
-
我在 Fedora 18 上的 GNU Emacs 24.2.1 上尝试过,它工作正常,抱歉。但是我系统上的钩子是
python-switch-to-python。 -
您在使用 gui 主循环时遇到问题。你用的是什么后端?尝试将其配置为使用
ipython --pylab而不是python -
@tcaswell 我实际上使用 matplotlib.use() 尝试了不同的后端,但不起作用。但是在cmd窗口中,它可以工作。我也尝试过 ipython,出现了一个图形窗口,但它没有情节就冻结了。我相信这篇文章描述了同样的问题here on Stackoverflow,差不多 1 年过去了,仍然没有真正回答这个问题......我相信它是如果您不介意使用相同的配置尝试它,则可以复制
-
我没有设置 Windows 框来做任何实际工作。当您启动解释器时,您是否向 python 传递了正确的线程参数?
matploblib.use()需要在导入plt之前运行。我怀疑您的系统配置不正确。 -
这是我在 emacs 中运行 Python shell 的命令:
C:/Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab,我的 ipython 是 0.13.2,我的 python 是 2.7.5,默认后端是:TkAgg,正如我所说,它可以工作在 cmd 窗口下,所以我相信这不是后端导致的问题。我也试过 QT。
标签: python emacs matplotlib