question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

raw.plot(block=True) freezes the jupyter kernel forever

See original GitHub issue

Describe the bug

When plotting continuous “raw” data and specify block=True, everything works well until you try to close the figure. Control is never handed back to the command line. This does not occur when using command line ipython, but does occur when using Spyder or a Jupyter notebook.

Steps and/or code to reproduce

In Spyder or a notebook:

import mne
data_path = mne.datasets.sample.data_path()
raw = mne.io.read_raw_fif(data_path +'/MEG/sample/sample_audvis_raw.fif')
raw.plot(block=True)

Close the plotting window. The Jupyer kernel now hangs.

Expected results

After closing the window, the Jupyter kernel should become responsive again.

Actual results

Jupyter kernel never becomes responsive.

Additional information

Platform:      Linux-4.4.0-148-generic-x86_64-with-debian-stretch-sid
Python:        3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)  [GCC 7.3.0]
Executable:    /work/modules/Ubuntu/14.04/amd64/common/anaconda3/latest/envs/neuroimaging/bin/python
CPU:           x86_64: 8 cores
Memory:        15.6 GB

mne:           0.18.1 (also tested this on current master)
numpy:         1.16.4 {blas=mkl_rt, lapack=mkl_rt}
scipy:         1.2.1
matplotlib:    3.1.0 {backend=Qt5Agg}

sklearn:       0.21.2
nibabel:       2.4.1
mayavi:        4.6.2 {qt_api=pyqt5, PyQt5=5.9.2}
cupy:          Not found
pandas:        0.24.2
dipy:          Not found

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
wmvanvlietcommented, Oct 12, 2022

This still breaks for me in Spyder, but not in plain ipython or in a notebook:

from matplotlib import pyplot as plt
plt.plot([1, 2, 3, 4])
plt.show(block=True)

However, @mvonflotow’s suggestion of disabling Spyder’s active support did the trick. I’m guessing there’s some weird interaction between the Qt thread spawned by the QtConsole component that Spyder uses and the block=True behavior. I’ll file the issue there.

0reactions
cbrnrcommented, Oct 12, 2022

I cannot reproduce the issue, the minimal example does not block execution in both a regular Jupyter notebook and inside VS Code. Maybe you do not have the latest versions of the involved packages (i.e. Matplotlib, Jupyter)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jupyter Notebook + Matplotlib; Freeze on plot.show()
Is this in Jupyter Notebook or something of the sort? Usually you shouldn't be able to do matplotlib.use('QT4Agg') import matplotlib.
Read more >
How to Fix Kernel Error in Jupyter Notebook
When the system encounters difficulties locating the path which certain programs will run, this error is known as a kernel error in Jupyter ......
Read more >
Rendering Jupyter notebooks with inline plots freezes ... - GitLab
Create a Jupyter notebook with an inline plot and commit it to a GitLab ... plots, the CPU usage goes up causing the...
Read more >
Jupyter Notebook 6.5.2 documentation - Read the Docs
The execution behavior of a cell is determined by the cell's type. There are three types of cells: code cells, markdown cells, and...
Read more >
Plotly - notebook / Very slow render with many graphs
Is this a plotly thing or a jupyter notebook thing or a mix of both? ... seems to freeze up and with 15+...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found