Reputation: 1054
I can't use the debugger in ipython after importing anything pyqt related.
If I don't import anything and debug an error post-mortem like
$ 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>
all is well, but if I start ipython3 with the pyqt5 backend I get
$ 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.
[...]
I am not developing with qt, I only use it as the backend for matplotlib. I know that this question is very vague, but I don't know where to look for a solution.
I'm on Ubuntu 18.04, Python 3.6.9, ipython 7.14.0, pyqt5 5.14.2.
Upvotes: 5
Views: 260
Reputation: 1054
The problem is resolved with upgrading the pip package "prompt_toolkit" via
$ pip3 install --upgrade prompt_toolkit # optionally --user
For me it went from version 2.0.10 to 3.0.5.
Upvotes: 1
Reputation: 1519
As far as your problem is concerned, I have made a couple of searches around that specific error and I have found that this error entirely belongs to ipyhton
as the same kind of issues have been already available on ipython official github-issues as given here:
I was also struck with the same problem but I have alternatives. I have performed a couple of tests to debug using ipython
. Here are some combinations that can resolve your problem.
- Either by using
~$ ipython --pylab=qt5
- Or by using
~$ ipython3 --pylab=qt4
Update
You can use either of these methods to get your work done. But make sure, you have follow all of the given steps one by one.
Method.1
ipython --pylab=qt5
For this, open your terminal and run the following commands:
~$ sudo killall apt apt-get
~$ sudo rm /var/lib/apt/lists/lock && sudo rm /var/cache/apt/archives/lock && sudo rm /var/lib/dpkg/lock* && sudo dpkg --configure -a && sudo apt update
After that, you have to install these things as follows:
~$ sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
~$ sudo apt-get install python-pip
~$ pip install ipython
~$ sudo apt-get install python-pyqt5
~$ pip install pyside2 && pip install matplotlib
After installing all of these modules, just run this command: ipython --pylab=qt5
, you will see with few exceptions
, ipython
process will be instantiated.
Method.2
ipython3 --pylab=qt4
For this, open your terminal and run the following commands:
~$ sudo killall apt apt-get
~$ sudo rm /var/lib/apt/lists/lock && sudo rm /var/cache/apt/archives/lock && sudo rm /var/lib/dpkg/lock* && sudo dpkg --configure -a && sudo apt update
After that, you have to install these things as follows:
~$ sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
~$ sudo apt-get install python3-pip
~$ pip3 install ipython3
~$ sudo apt-get install python3-pyqt4
~$ pip3 install pyside2 && pip3 install matplotlib
After installing all of these modules, just run this command: ipython3 --pylab=qt4
, you will see ipython
process will be instantiated.
Now, you can use either of the above-given techniques to use it as the backend for matplotlib
. Here is the output of one of the tests from the above techniques:
ipython3 --pylab=qt4
Upvotes: 0