matplotlib / matplotlib/ipympl

Automatically started kernels in jupyterlab break matplotlib

Abierto
#136 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Jupyter Notebook
Estrellas
1.7k
Forks
234
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el problema con el entorno de conda indicado, jupyter lab y el ejemplo %matplotlib widget. Compara el estado del kernel después de volver a abrir el notebook con el estado después de usar Kernel > Shut Down Kernel y Kernel > Restart Kernel; se considera terminado cuando el notebook vuelto a abrir renderiza el gráfico sin salida negra ni advertencias No such comm.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
jupyter-notebook, matplotlib, numpy
Área
backend, frontend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.