emacs中的python shell在使用matplotlib时会冻结 [英] python shell in emacs freezes when using matplotlib

查看:341
本文介绍了emacs中的python shell在使用matplotlib时会冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


  1. run emacs -Q 在cmd窗口

  2. 打开一个.py文件

  3. Mx ,然后运行 python-shell-switch-to-shell RET code> RET ,那么我有python shell准备好了

  4. 我把以下代码,然后:




  Python 2.7.3(默认,2012年4月10日,23:31:26)[MSC v.1500 32位(Intel)] on win32 
输入help,copyright,credits或license了解更多信息。
>>> import matplotlib.pyplot as plt
>>>> plt.ion()
>>>> plt.plot([1,2,3])
[< matplotlib.lines.Line2D object at 0x03068610>]
>>>


其实没有显示,shell是冻结,例如,当我输入:


 >>> print(hello)


没有发生什么...我避风港没有测试其他绘图工具,但matplotlib。我不知道是否是一个错误,我搜索了一段时间,这里,虽然谷歌,但没有运气。我的系统是:Emacs 24.3 32位Windows,在Windows 7下。如果其他人可以重复同样的问题,我会报告这是一个错误



谢谢! p>

更新:我使用ipython作为python shell:

  C: /Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab 

然后,我输入 figure();情节([1,2,3]),如预期的那样,数字弹出并冻结,然后我做了: Cc Cd 它运行 comint-send-eof ,该图实际上得到更新 !,但是我的ipython shell会话也被终止了以下msg:

 在[6]中:
你真的要退出([y] / n)吗?
追溯(最近的最后一次调用):
文件C:/Python27/Scripts/ipython-script.py,第9行在< module>
load_entry_point('ipython == 0.13.1','console_scripts','ipython')()
SystemExit

如果您怀疑这是一个IPython错误,请报告在
https://github.com/ipython/ipython/issues
或发送电子邮件到邮件列表ipython-dev@scipy.org

您可以打印使用%tb进行更详细的追溯,或使用%debug
进行交互式调试。

可通过以下方式启用针对错误报告目的的详细追溯:
%config Application.verbose_crash = True

这里有任何有用的线索?

解决方案

一个解决方案是:

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

ipython-script.py的调用中的参数控制台是重要的! / strong>



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


I previously thought that was the issue with ipython, but today i tested again, here is what i did:

  1. run emacs -Q in cmd window
  2. open a .py file
  3. M-x, then run python-shell-switch-to-shell, RET, RET, then i have the python shell ready
  4. i put the following code then:

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>]
>>>

actually after this, no figure shows up, and the shell is frozen, e.g., when I input:

>>> print("hello")

nothing happened...I haven't tested other plotting tools but matplotlib. i don't know if it is a bug, i've searched for a while, here and though google, but no luck. my system is: Emacs 24.3 32 bit for Windows, under Windows 7. if others can duplicate same issue as here, i will report this as a bug

thanks!

update: i used ipython as the python shell by:

C:/Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab

then, i input figure(); plot([1,2,3]), as expected, the figure popup and freezes, then i did: C-c C-d which runs comint-send-eof, the figure actually get updated!, but my ipython shell session is also terminated with the following msg:

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

any helpful clue here?!

解决方案

one solution is:

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

The Argument console in the call of ipython-script.py is the important one!

In Python 3 with qt backend it works for me. I don't know how it works with py 2.7. (should be no problem if these arguments are supported for ipytho-script.py)

这篇关于emacs中的python shell在使用matplotlib时会冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆