gpt4 book ai didi

python - pylab 导入后,ipython 调试器充斥着 Qt 错误

转载 作者:行者123 更新时间:2023-12-03 17:11:57 24 4
gpt4 key购买 nike

导入任何与 pyqt 相关的内容后,我无法在 ipython 中使用调试器。

如果我不导入任何东西并调试像

$ ipython3

In [1]: abc
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-03cfd743661f> in <module>
----> 1 abc

NameError: name 'abc' is not defined

In [2]: %debug
> <ipython-input-1-03cfd743661f>(1)<module>()
----> 1 abc

ipdb>

一切都很好,但是如果我使用 pyqt5 后端启动 ipython3,我会得到
$ ipython3 --pylab=qt5

In [1]: abc
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-03cfd743661f> in <module>
----> 1 abc

NameError: name 'abc' is not defined

In [2]: %debug
> <ipython-input-1-03cfd743661f>(1)<module>()
----> 1 abc

ipdb> QObject: Cannot create children for a parent that is in a different thread.
(Parent is QApplication(0x2105860), parent's thread is QThread(0x1ccc6c0), current thread is QThread(0x7fe7940021f0)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QApplication(0x2105860), parent's thread is QThread(0x1ccc6c0), current thread is QThread(0x7fe7940021f0)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QApplication(0x2105860), parent's thread is QThread(0x1ccc6c0), current thread is QThread(0x7fe7940021f0)
QObject: Cannot create children for a parent that is in a different thread.
[...]

我不是用 qt 开发的,我只用它作为 matplotlib 的后端。我知道这个问题很模糊,但我不知道去哪里寻找解决方案。

我使用的是 Ubuntu 18.04、Python 3.6.9、ipython 7.14.0、pyqt5 5.14.2。

最佳答案

通过升级pip包“prompt_toolkit”解决了问题

$ pip3 install --upgrade prompt_toolkit  # optionally --user 

对我来说,它从 2.0.10 版升级到了 3.0.5 版。

关于python - pylab 导入后,ipython 调试器充斥着 Qt 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61962118/

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