matplotlib / matplotlib/ipympl

Automatically started kernels in jupyterlab break matplotlib

Ouverte
#136 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Jupyter Notebook
Étoiles
1.7k
Forks
234
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par reproduire le problème avec l’environnement conda indiqué, jupyter lab et l’exemple %matplotlib widget. Comparez l’état du kernel après avoir rouvert le notebook avec l’état après avoir utilisé Kernel > Shut Down Kernel et Kernel > Restart Kernel ; la tâche est terminée lorsque le notebook rouvert affiche le graphique sans sortie noire ni avertissements No such comm.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
jupyter-notebook, matplotlib, numpy
Domaine
backend, frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.