cle*_*sch 5 python ipython ipdb
导入任何与 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>
Run Code Online (Sandbox Code Playgroud)
一切都很好,但是如果我使用 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.
[...]
Run Code Online (Sandbox Code Playgroud)
我不是用 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
Run Code Online (Sandbox Code Playgroud)
对我来说,它从版本 2.0.10 升级到了 3.0.5。