Notebook: Notebook doesn't display inline plots on startup after some time

Created on 18 Jul 2016  路  7Comments  路  Source: jupyter/notebook

Hi,

this is my first time posting on GitHub so excuse me if I am doing it wrong. I could not find this issue being reported or addressed by anyone.
I am regularly experiencing an annoying trouble with Jupyter notebooks. Namely after some time, notebooks fail to display the inline matplotlib plots on startup but instead simply display something like for plots of the notebook. I could not figure out what triggers this change of behavior. The annoying part is that to get a new notebook that will display the plots on startup, I have to recreate a new notebook from scratch by copy pasting and running every cell, and my data analysis notebooks are usually pretty long...
First, why is this happening? I might be doing something wrong without knowing it.
Second, is there an easier way to recreate a "working" notebook without copy pasting the cells. Note that using the "Make a copy..." function does not help.

I am on Windows 10, python 2.7, IPython 4.0.0

Most helpful comment

Ah, you're using SVG figures. I'd guess that when the figures disappear, it's because the notebook has become untrusted. Are you running it on different computers, synchronised by something like Dropbox or Github?

Output formats like HTML and SVG are able to send code to the kernel to execute, so we have to be careful about displaying them, because it's a security risk. If a notebook is recognised as one that you have run all of and saved on this computer before, it is _trusted_, and those outputs are displayed. If any of the outputs weren't generated and saved on this computer, it's untrusted, and you can't see potentially dangerous outputs.

Possible workarounds:

  • Use PNG plots - PNGs can't send code to the kernel (except potentially by exploiting browser bugs), so they don't need to be trusted.
  • If you're sure of where the notebook came from, you can manually mark it as trusted in the file menu.

All 7 comments

Namely after some time, notebooks fail to display the inline matplotlib plots on startup but instead simply display something like for plots of the notebook.

I'm not sure what you're seeing - are the plots there at first and then they disappear? Or do they never show up, but you expect them to? How long does this take?

What browser are you using? Can you try a different one? Do you have any extensions, either to your browser or to the notebook itself?

The plots never appear while they should (they do for the first n-th times I open the notebook). Then, something happens (I don't know what) and I only see something like instead of the plots. If I replot them, then they are normally displayed but once I close the notebook and reopen it, they again are not displayed. I thus have to recreate the notebook from scratch for it to work again. Note that I am using the following for plotting:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'

I am using Firefox 32-bit (just realized that it is the 32-bit version while my machine is 64-bit).
I experienced this problem for quite some time. In the beginning I was using no extensions. Now I use several extensions : execute time, (some) LaTeX environment, scratchpad, autosavetime, codefolding, initialization cells, collapsible headings and table of contents (2).

I will try on Chrome to see if anything changes.

If you can make it happen with an example notebook you don't mind sharing, please upload the notebook once it's happened, so we can see if the problem is that the data is disappearing, or that it's just not showing up for you.

Here is a notebook where I have this problem. It is small and light compared to my other notebooks so it's good for checking I guess.

Distributions.zip

Ah, you're using SVG figures. I'd guess that when the figures disappear, it's because the notebook has become untrusted. Are you running it on different computers, synchronised by something like Dropbox or Github?

Output formats like HTML and SVG are able to send code to the kernel to execute, so we have to be careful about displaying them, because it's a security risk. If a notebook is recognised as one that you have run all of and saved on this computer before, it is _trusted_, and those outputs are displayed. If any of the outputs weren't generated and saved on this computer, it's untrusted, and you can't see potentially dangerous outputs.

Possible workarounds:

  • Use PNG plots - PNGs can't send code to the kernel (except potentially by exploiting browser bugs), so they don't need to be trusted.
  • If you're sure of where the notebook came from, you can manually mark it as trusted in the file menu.

Yes indeed I do synchronize them on several computers. Marking them as trusted works indeed and the figures reappear!
I guess it was a trivial problem and I feel sorry for wasting your time with this. Thank you very much for your help!

No worries, this stuff can be confusing. Closing as it appears to be working as designed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pylang picture pylang  路  3Comments

mowe96 picture mowe96  路  3Comments

ehossain1982 picture ehossain1982  路  3Comments

qnicole-zakka picture qnicole-zakka  路  3Comments

Foadsf picture Foadsf  路  3Comments