pyqtgraph blocking ipython console

1,132 views
Skip to first unread message

john lunzer

unread,
Aug 4, 2014, 12:56:35 PM8/4/14
to pyqt...@googlegroups.com
Hello, I previously was pyqtgraph on top of a pythonxy installation.

I recently installed Anaconda because I needed 64bit python. I cleaned up my path variables to make sure there were no pythonxy entries.

 I previously was able to type something like 

import pyqtgraph
pg.image()

and have a window pop up and still be able to interact with the console.

Now when I try the same code the window hangs and I can no longer interact with the console, it seems like it initializes because if I have another window on top of it and then minimize that window there is an image of that previously window in the space where the pyqtgraph window should be. 

I should note that if I run the examples they run fine but still block the console.

Any ideas on how to get the previous normal behavior back?

Luke Campagnola

unread,
Aug 4, 2014, 1:08:55 PM8/4/14
to pyqt...@googlegroups.com
On Mon, Aug 4, 2014 at 12:56 PM, john lunzer <lun...@gmail.com> wrote:
Hello, I previously was pyqtgraph on top of a pythonxy installation.

I recently installed Anaconda because I needed 64bit python. I cleaned up my path variables to make sure there were no pythonxy entries.

 I previously was able to type something like 

import pyqtgraph
pg.image()

and have a window pop up and still be able to interact with the console.

Now when I try the same code the window hangs and I can no longer interact with the console

Hi John,

Is it possible that you are using PySide instead of PyQt? Only PyQt supports using the interactive interpreter this way.

john lunzer

unread,
Aug 4, 2014, 1:14:09 PM8/4/14
to pyqt...@googlegroups.com
When I do a pg.systemInfo() it tells me that it is using PyQt4.

john lunzer

unread,
Aug 4, 2014, 1:19:10 PM8/4/14
to pyqt...@googlegroups.com
Actually, I was mistaken about the console hanging. There are some instances of running code when the console hangs, but in the simple case of 

import pyqtgraph as pg
pg.image()

the only symptom is that the window content never renders.


On Monday, August 4, 2014 1:08:55 PM UTC-4, Luke Campagnola wrote:

john lunzer

unread,
Aug 6, 2014, 8:28:37 AM8/6/14
to pyqt...@googlegroups.com
I did a test of pyqtgraph on two linux systems and a windows system, all that use PyQt4 rather than pyside (or so pyqtgraph relays to me via pg.systemInfo). My results were the same.

Specifically I am running your ImageView.py example.

First I comment out the import initExample, so that it uses my installed version of pyqtgraph.

Then I comment out if __name__ == '__main__': and everything below it.

If I run the script nothing shows up but in the IPython console I can interact with all the variables and objects how I would like to.

If I then type into the IPython console, QtGui.QApplication.instance().exec_() the window shows up but now the IPython console is blocked, which I do not want.

If I then close the window and immediately type QtGui.QApplication.instance().exec_() and run it, the kernel appears to hang and I can't recover from it without killing the kernel. If I type win.show() before the exec_() command then it won't hang and the window will show up again.

I never really had to deal with this with my previous pyqtgraph setup. 

Can you explain to me what is going on, or forward me to somewhere that explains it, and possibly suggest a solution to showing the window without the IPython console getting blocked?

Luke Campagnola

unread,
Aug 6, 2014, 2:58:12 PM8/6/14
to pyqt...@googlegroups.com
On Wed, Aug 6, 2014 at 8:28 AM, john lunzer <lun...@gmail.com> wrote:
I did a test of pyqtgraph on two linux systems and a windows system, all that use PyQt4 rather than pyside (or so pyqtgraph relays to me via pg.systemInfo). My results were the same.

Specifically I am running your ImageView.py example.

First I comment out the import initExample, so that it uses my installed version of pyqtgraph.

Then I comment out if __name__ == '__main__': and everything below it.

If I run the script nothing shows up but in the IPython console I can interact with all the variables and objects how I would like to.

When I run the example after making the same changes, I see the ImageView window as expected, both the window and the ipython prompt are responsive. This works both for Ipython  (command `ipython -i examples/ImageView.py`) and for the plain interactive python shell  (command `python -i examples/ImageView.py`).

Can you give me the details of your anaconda installation procedure so I can try to reproduce this?

 
If I then type into the IPython console, QtGui.QApplication.instance().exec_() the window shows up but now the IPython console is blocked, which I do not want.

This is expected; the Qt event loop will block the Ipython event loop. That's why we rely on PyQt to hook into the ipython event loop instead.

john lunzer

unread,
Aug 6, 2014, 3:05:47 PM8/6/14
to pyqt...@googlegroups.com
It is the most recent (within the last three days) Anaconda install available from: http://continuum.io/downloads . In both the Windows and Linux case it is the 64bit 2.7 version. PyQtGraph is installed via pip, but I also tried to install it from the download via setup.py and achieved the same results. Nothing else was changed in each case.

Luke Campagnola

unread,
Aug 6, 2014, 3:55:13 PM8/6/14
to pyqt...@googlegroups.com
On Wed, Aug 6, 2014 at 3:05 PM, john lunzer <lun...@gmail.com> wrote:
It is the most recent (within the last three days) Anaconda install available from: http://continuum.io/downloads . In both the Windows and Linux case it is the 64bit 2.7 version. PyQtGraph is installed via pip, but I also tried to install it from the download via setup.py and achieved the same results. Nothing else was changed in each case.

Ok, just tried again via anaconda, same results. I did this:

1. Download anaconda, install to home directory
2. ~/anaconda/bin/pip install pyqtgraph
3. Copied system Qt libs into anaconda to work around this bug: https://github.com/ContinuumIO/anaconda-issues/issues/63
4. Copied ~/anaconda/lib/python2.7/site-packages/pyqtgraph/examples/ImageView.py  and edited it to remove the lines as you described
5. Ran the example with ~/anaconda/bin.python -i ImageView.py

The window appears and is interactive, as is the python prompt. There was a delay of a few seconds while scipy.weave did some compiling (but note weave is disabled in the development branch).

Not sure where to go from here..

john lunzer

unread,
Aug 7, 2014, 7:59:12 AM8/7/14
to pyqt...@googlegroups.com
That list of steps was good. After running through your steps and it working I realized I left out one important detail. I've been running the code from Spyder.

These days by default Spyder runs an IPython console. There is an option in the IPython settings Graphics tab called "Graphics Backend". By default this is set to "Automatic", which from the description seems that it is tailored towards interacting with matplotlib graphics windows. Whatever "Automatic" is setting must be blocking the Qt windows. You can set the "Graphics Backend" to "Qt" (duh!) and everything works as it should. 

As these are default settings in Spyder and it seems that lot of people use Spyder, it might be worth mentioning it in early in the docs somewhere to switch to the Qt graphics backend. Just a thought.

Michael Schneider

unread,
Oct 27, 2014, 11:56:27 PM10/27/14
to pyqt...@googlegroups.com
Thanks for documenting this issue, I've had the same problem (for the same reason, i.e. spyder using "Automatic" backend for ipython console). I finally manged to find this thread when I realized that the problem does not occur when using spyder with the normal python interpreter.

john lunzer

unread,
Oct 29, 2014, 7:25:25 AM10/29/14
to pyqt...@googlegroups.com
I'm glad it could help somebody!

Chris

unread,
Dec 9, 2014, 6:40:06 PM12/9/14
to pyqt...@googlegroups.com
I have a similar issue, it might partly be an Anaconda issue. I'm running Anaconda on Windows (the latest 64 bit 2.7 version, IPython 2.3.1, Spyder 2.3.1). I tried both the standalone IPython QtConsole and the one in Spyder. In Spyder, whether the graphics backend is "Qt" or "Automatic" doesn't change anything for me. I tested various things:

IPython                pg.image()                  window hangs until app.exec_(), then works but blocks console
IPython                pyqtgraph.examples.run()    works but blocks console
IPython %gui qt        pg.image()                  works
IPython %gui qt        pyqtgraph.examples.run()    window pops up, disappears and console hangs

Spyder nographics      pg.image()                  window hangs until app.exec_(), then works but blocks console
Spyder nographics      pyqtgraph.examples.run()    works but blocks console
Spyder                 pg.image()                  works
Spyder                 pyqtgraph.examples.run()    window pops up, disappears and console hangs


notes:
%gui qt: run this IPython magic once you start IPython
app.exec_(): beforehand run: import sys, from PyQt4 import QtGui, app = QtGui.QApplication(sys.argv)
nographics: disable the "activate support" checkbox under Preferences->Ipython console->Graphics

john lunzer

unread,
Dec 11, 2014, 1:54:43 PM12/11/14
to pyqt...@googlegroups.com
I just updated my Anaconda to match your configuration and I'm not getting any blocking. Based on that I can only recommend reinstalling Anaconda and pyqtgraph.
Reply all
Reply to author
Forward
0 new messages