5

我以前认为这是 IPython 的问题,但今天我再次测试,这是我所做的:

  1. emacs -Q在cmd窗口中运行
  2. 打开一个 .py 文件
  3. M-x, 然后运行python-shell-switch-to-shell​​,RETRET. 然后我准备好了 Python shell
  4. 然后我输入以下代码:
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-dwhich runs 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

这里有什么有用的线索吗?!

4

2 回答 2

4

一种解决方案是:

(setq python-shell-interpreter "C:\\YourPython3Dist\\python.exe"
      python-shell-interpreter-args "-i C:\\YourPython3Dist\\Scripts\\ipython3-script.py console --pylab=qt")

ipython-script.py 调用中的参数console很重要!

在带有 qt 后端的 Python 3 中,它适用于我。我不知道它如何与 py 2.7 一起使用。(如果支持这些论点应该没问题ipytho-script.py

于 2013-09-11T15:22:30.027 回答
1

我认为需要一段时间才能解决问题。直到某些 Windows 用户实际调试 python.el。

在那之前,为什么不试试Emacs IPython Notebook呢?它是 Emacs 的更好的 IPython 绑定。您不需要使用笔记本部分。您可以将其视为 python.el 中 python shell 的替代品。(免责声明:我是作者)

于 2013-06-16T00:17:04.903 回答