matplotlib / matplotlib/ipympl

Automatically started kernels in jupyterlab break matplotlib

Aperta
#136 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Jupyter Notebook
Stelle
1.7k
Fork
234
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

When a jupyterlab server is shut down, it remembers which files were open the next time it starts. When the jupyterlab server is restarted, it opens those files and starts a kernel for each one. These kernels are cursed. If %matplotlib widget is used in any of these open files, matplotlib will show a black image instead of the expected plot. Errors like [IPKernelApp] WARNING | No such comm: fcef8c0be3a345e493e771adbbb0df16 appear in the server's standard out. Restarting the kernel does not help. The kernel must be shut down and then restarted. Only then will the notebook display plots correctly.

How to reproduce

  1. Create a new conda environment with jupyterlab and matplotlib installed and start the server.
conda create -n temp -c conda-forge jupyterlab==1.0.9 matplotlib==3.1.1 ipympl==0.3.3
conda activate temp
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter lab
  1. Create a new notebook in JupyterLab and leave it open.

  2. Shutdown the server and restart it. Note that the new file has a running kernel.

  3. Put some plotting code using %matplotlib widget in the notebook and run it. A black box will appear instead of a plot. Error messages will stream in the console.

%matplotlib widget
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 1, 500)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

fig, ax = plt.subplots()

ax.fill(x, y, zorder=10)
ax.grid(True, zorder=5)
plt.show()
  1. Navigate to Kernel > Shut Down Kernel and then Kernel > Restart Kernel. Run the notebook again and the plots will appear.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il problema con l’ambiente conda indicato, jupyter lab e l’esempio %matplotlib widget. Confronta lo stato del kernel dopo aver riaperto il notebook con lo stato dopo aver usato Kernel > Shut Down Kernel e Kernel > Restart Kernel; il lavoro è completato quando il notebook riaperto esegue il rendering del grafico senza output nero né avvisi No such comm.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
jupyter-notebook, matplotlib, numpy
Ambito
backend, frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.