she*_*per 5 python emacs matplotlib
我以前认为这是 IPython 的问题,但今天我再次测试,这是我所做的:
emacs -Q
在cmd窗口中运行M-x
,然后运行python-shell-switch-to-shell
,RET
和RET
。然后我准备好了 Python shellRun Code Online (Sandbox Code Playgroud)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>] >>>
实际上在此之后,没有数字出现,并且外壳被冻结,例如,当我输入时:
Run Code Online (Sandbox Code Playgroud)>>> print("hello")
什么也没发生……我没有测试过其他绘图工具,但 matplotlib。不知道是不是bug 我已经在这里和谷歌搜索了一段时间,但没有运气。我的系统是:Emacs 24.3 32 位 for Windows,在 Windows 7 下。如果其他人可以复制与此处相同的问题,我会将其报告为错误。
我通过以下方式使用 IPython 作为 Python shell:
C:/Python27/python.exe -i C:/Python27/Scripts/ipython-script.py --pylab
Run Code Online (Sandbox Code Playgroud)
然后,我figure(); plot([1,2,3])
按预期输入,图形弹出并冻结。然后我做了:C-c C-d
which running 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
Run Code Online (Sandbox Code Playgroud)
这里有什么有用的线索吗?!
一种解决方案是:
(setq python-shell-interpreter "C:\\YourPython3Dist\\python.exe"
python-shell-interpreter-args "-i C:\\YourPython3Dist\\Scripts\\ipython3-script.py console --pylab=qt")
Run Code Online (Sandbox Code Playgroud)
console
ipython-script.py 调用中的参数是重要的!
在带有 qt 后端的 Python 3 中,它对我有用。我不知道它如何与 py 2.7 一起使用。(如果这些参数得到支持,应该没问题ipytho-script.py
)