ipython / ipython/ipykernel

No matplotlib output if sharing a cell with a list comprehension

Ouverte
#514 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
734
Forks
412
Merge moyen
1 j 5 h
PR mergées (30 j)
8

Description

I'm encountering the following behaviour in a jupyter notebook: An attempt to plot with matplotlib fails if there's a list comprehension in the same cell as the plotting code. I tested a few other python expressions (`1 + 1`, `True == False`, simple for loop) and they didn't cause the plot to disappear as list comprehensions do. It seems as if the figure is generated but doesn't show, because a later call to `plt.show()` presents the plot with a different colored line. This is probably better demonstrated in the gif below.

![out](https://user-images.githubusercontent.com/2564187/84174615-b94e4a00-aa76-11ea-919d-1bff9c13b349.gif)

Tested on both python 3.7.7 and 3.8.3, firefox 77.0.1, and chromium 83.0.4103.97. Tried on two different machines, both running arch linux if that matters. Got the same result for all configurations. Opened a ticket for jupyter notebook first (https://github.com/jupyter/notebook/issues/5523), and they suggested to ask here.

Here's my `requirements.txt`:
```
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
#
attrs==19.3.0 # via jsonschema
backcall==0.1.0 # via ipython
bleach==3.1.5 # via nbconvert
cycler==0.10.0 # via matplotlib
decorator==4.4.2 # via ipython, traitlets
defusedxml==0.6.0 # via nbconvert
entrypoints==0.3 # via nbconvert
ipykernel==5.3.0 # via notebook
ipython-genutils==0.2.0 # via nbformat, notebook, traitlets
ipython==7.15.0 # via ipykernel
jedi==0.17.0 # via ipython
jinja2==2.11.2 # via nbconvert, notebook
jsonschema==3.2.0 # via nbformat
jupyter-client==6.1.3 # via ipykernel, notebook
jupyter-core==4.6.3 # via jupyter-client, nbconvert, nbformat, notebook
kiwisolver==1.2.0 # via matplotlib
markupsafe==1.1.1 # via jinja2
matplotlib==3.2.1 # via -r requirements.in
mistune==0.8.4 # via nbconvert
nbconvert==5.6.1 # via notebook
nbformat==5.0.6 # via nbconvert, notebook
notebook==6.0.3 # via -r requirements.in
numpy==1.18.5 # via matplotlib
packaging==20.4 # via bleach
pandocfilters==1.4.2 # via nbconvert
parso==0.7.0 # via jedi
pexpect==4.8.0 # via ipython
pickleshare==0.7.5 # via ipython
prometheus-client==0.8.0 # via notebook
prompt-toolkit==3.0.5 # via ipython
ptyprocess==0.6.0 # via pexpect, terminado
pygments==2.6.1 # via ipython, nbconvert
pyparsing==2.4.7 # via matplotlib, packaging
pyrsistent==0.16.0 # via jsonschema
python-dateutil==2.8.1 # via jupyter-client, matplotlib
pyzmq==19.0.1 # via jupyter-client, notebook
send2trash==1.5.0 # via notebook
six==1.15.0 # via bleach, cycler, jsonschema, packaging, pyrsistent, python-dateutil, traitlets
terminado==0.8.3 # via notebook
testpath==0.4.4 # via nbconvert
tornado==6.0.4 # via ipykernel, jupyter-client, notebook, terminado
traitlets==4.3.3 # via ipykernel, ipython, jupyter-client, jupyter-core, nbconvert, nbformat, notebook
wcwidth==0.2.4 # via prompt-toolkit
webencodings==0.5.1 # via bleach

# The following packages are considered to be unsafe in a requirements file:
# setuptools
```

Let me know if I can be of any use for debugging.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

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