gpt4 book ai didi

使用 matplotlib 时 Emacs 中的 Python shell 卡住

转载 作者:太空狗 更新时间:2023-10-30 02:47:08 29 4
gpt4 key购买 nike

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

  1. 在 cmd 窗口中运行 emacs -Q
  2. 打开一个 .py 文件
  3. M-x,然后运行 ​​python-shell-switch-to-shellRETRET。然后我准备好 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,我还没有测试过其他绘图工具。我不知道这是不是一个错误。我在这里和谷歌搜索了一段时间,但没有运气。我的系统是:适用于 Windows 的 Emacs 24.3 32 位,在 Windows 7 下。如果其他人可以重复与此处相同的问题,我会将其报告为错误。

我通过以下方式使用 IPython 作为 Python shell:

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

然后,我输入figure(); plot([1,2,3]),正如预期的那样,图形弹出并卡住。然后我做了:运行 comint-send-eofC-c C-d,这个数字实际上得到了更新!但是我的 IPython shell session 也因以下消息而终止:

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

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

最佳答案

一个解决方案是:

(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 支持这些参数应该没问题)

关于使用 matplotlib 时 Emacs 中的 Python shell 卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17117074/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com