Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%matplotlib qt5 freezes notebook execution #2025

Open
godaygo opened this issue Jan 6, 2017 · 6 comments
Open

%matplotlib qt5 freezes notebook execution #2025

godaygo opened this issue Jan 6, 2017 · 6 comments

Comments

@godaygo
Copy link

godaygo commented Jan 6, 2017

After updating to Python 3.6 and PyQt 5.7.1, when I use magic %matplotlib qt5 and Restart & Run All button the execution freezes after cell with %matplotlib qt5. (When I evaluate notebook cell by cell it works OK as expected)

qt

The problem relates only to qt5 backend (PyQt 5.7.1).

When I set up c.InteractiveShellApp.matplotlib = 'qt5' in IPython config file, %matplotlib qt5 works OK. When I commented it again execution freezes. Code to play with:

In[1]:  %matplotlib qt5
        import matplotlib.pyplot as plt

In[2]:  fig, ax = plt.subplots(figsize=(12, 8), facecolor='w')
        ax.plot([1,2,3])
        plt.show()

Also for all related buttons Run All, Run All Below the behavior is the same after kernel restart.

Python 3.6
IPython 5.1.0
ipykernel 4.5.2
notebook 4.3.1
PyQt5 5.7.1
Windows 10

@godaygo godaygo changed the title %matplotlib qt5 freezes execution %matplotlib qt5 freezes notebook execution Jan 6, 2017
@godaygo godaygo changed the title %matplotlib qt5 freezes notebook execution %matplotlib qt5 freezes notebook execution Jan 6, 2017
@gnestor
Copy link
Contributor

gnestor commented Jan 26, 2017

Ping @Carreau

@Carreau
Copy link
Member

Carreau commented Jan 26, 2017

Yeah, I think we have seen this one before. The problem is we have no clue why.
I'm going to guess a ZMQ/Qt event loop integration.

It's really complex to debug, and none of us a Qt5 experts. I'll add that on my loong todo list.

@gnestor gnestor added this to the Not Notebook milestone Jan 26, 2017
@kronos29296
Copy link

I have a similar problem where if I use %pylab with qt5 freezes when I restart and run all. The plot is displayed when I do a reconnect. Any form of run all with qt5 freezes. I have tried it with %matplotlib and the same problem persists.

When I reconnect though the plot is displayed, the cells are not numbered and still have *. There are no problems when I use something else like tk though.

@IVN-tone
Copy link

IVN-tone commented Jul 29, 2020

Does anybody know the solution of this problem? I have the same issue. When I try to execute simple plot:

import pyqtgraph as pg import numpy as np x = np.random.normal(size=1000) y = np.random.normal(size=1000) pg.plot(x, y, pen=None, symbol='o') ## setting pen=None disables line drawing

but when I try work even with simple window:

import sys from PyQt5 import QtGui def window(): app = QtGui.QApplication(sys.argv) w = QtGui.QWidget() b= QtGui.QLabel(w) b.setText("Hello World!") w.setGeometry(100,100,200,50) b.move(50,20) w.setWindowTitle('PyQt') w.show() sys.exit(app.exec_()) if __name__ == '__main__': window()

it freezes the notebook irreversibly.

@ChristofKaufmann
Copy link

This is also an issue in VS Code. See also the same issue described here: ipython/ipython#5629

@EricThomson
Copy link

EricThomson commented Oct 20, 2023

Just wanted to chime in with -- I have been experiencing this in Windows for years. When I use %matplotlib qt, and try to run another code cell, that cell hangs (with asterisk). Until I click the 'Interrupt the kernel' button, or run another code cell. Then the first cell runs. The second one hangs until I repeat that process.

Markdown cells run fine, and I can edit/delete other cells. It is only the Python interpreter that seems to be locked when in qt mode. You can imagine presentations/demos are fun 😅

I'm not sure if this is a Matplotlib or Jupyter or zmq or Qt thing (all of the above?), but it would be amazing if we could figure this out (maybe let's get together at Scipy and figure it out -- it's that easy right? 😄). Note I haven't actually tested this thoroughly in non-Windows OS. I easily could.

Edit: I'm on Windows 10 and using notebook 6.5.4 and waiting on this to be fixed: bokeh/jupyter_bokeh#195

So maybe with notebook 7 this will no longer be an issue? Will report back once all that is figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants
@Carreau @gnestor @EricThomson @kronos29296 @ChristofKaufmann @godaygo @IVN-tone and others