gpt4 book ai didi

ipython - 如何让基本的交互式 pyqtgraph 图在 IPython REPL 或 Jupyter 控制台中工作?

转载 作者:行者123 更新时间:2023-12-04 01:33:02 30 4
gpt4 key购买 nike

打字

import pyqtgraph as pg
pg.plot([1,2,3,2,3])

进入标准 Python REPL 打开一个包含数据图的窗口。在 IPython REPL 或 Jupyter 控制台中输入完全相同的代码,不会打开这样的窗口。

[可以通过键入 pg.QtGui.QApplication.exec_() 来显示该窗口,但随后 REPL 被阻止。

或者,当尝试退出 REPL 时会出现该窗口,并且需要确认。

这两个都非常不令人满意。]

如何使基本的交互式 pyqtgraph 绘图与 IPython REPL 一起使用?

[在使用 Python 3.5 和 3.6 以及 PyQt4 和 PyQt5(无 PySide)的 IPython 5.1.0 和 Jupyter 5.0.0 中观察到所描述的行为]

最佳答案

正如@titusjan 所建议的,解决方案是输入

%gui qt

(或该主题的一些变体:在发出任何 pyqtgraph(或一般的 PyQt)命令之前,在 IPython 中查看 %gui? 有哪些其他选项可用。

关于ipython - 如何让基本的交互式 pyqtgraph 图在 IPython REPL 或 Jupyter 控制台中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43424960/

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