hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

No output in jupyter.

Open LinuxIsCool opened this issue 2 years ago • 15 comments

ALL software version info

bokeh==3.3.2 holoviews==1.18.1 hvplot==0.9.0 jupyterlab==4.0.9 jupyterlab-widgets==3.0.9 jupyterlab_pygments==0.3.0 jupyterlab_server==2.25.2 panel==1.3.6

Python 3.10.12

Linux Kernel: 6.6.6-76060606-generic

Description of expected behavior and the observed behavior

Expecting hvplot to work in jupyter...

Complete, minimal, self-contained example code that reproduces the issue

import pandas as pd
import hvplot.pandas
import numpy as np

df = pd.DataFrame({'x':range(100), 'y': np.linspace(0,100,100)})

df.hvplot.line(x='x',y='y')

Stack traceback and/or browser JavaScript console output

In the web console in jupyter:

TypeError: Bokeh is undefined
Panel: ERROR: Unable to run Panel code because Bokeh or Panel library is missing

Screenshots or screencasts of the bug in action

No output:

image

However, if I refresh the web page on jupyter then I now see output:

image

LinuxIsCool avatar Dec 21 '23 22:12 LinuxIsCool

I downgraded from holoviews 1.18.1 to 1.18.0 and bokeh from bokeh from 3.3.2 to 3.3.1 and things are currently working.

LinuxIsCool avatar Dec 30 '23 05:12 LinuxIsCool

I have the same problem, but downgrading did not resolve the issue for me.

Refreshing the page appears to work occasionally. When it does (I do not know what triggers it?!) plotting hv elements in panels works for a while, but eventually disappear...

ea42gh avatar Dec 30 '23 20:12 ea42gh

It is likely some old js cache that messes things up.

Try the following steps.

  1. Clear the notebook and save.
  2. Close all the notebooks.
  3. Hard refresh the browser.

hoxbro avatar Dec 31 '23 07:12 hoxbro

Hi @ea42gh could you report whether following the steps suggest by @Hoxbro fixed your issue? I agree it's likely an issue with some cache. If you're using JupyterLab, you may also want to make sure you don't have multiple notebooks opened at the same time that run with various versions of Bokeh.

maximlt avatar Jan 02 '24 11:01 maximlt

@Hoxbro What do you mean by Clear the notebook and save?

LinuxIsCool avatar Jan 02 '24 20:01 LinuxIsCool

@Hoxbro I guess you mean Edit -> Clear Outputs of All Cells

The issue recurred for me with the downgraded versions.

I followed @Hoxbro steps and it did resolve the issue.

LinuxIsCool avatar Jan 02 '24 20:01 LinuxIsCool

Just saw these messages: The cache issue had occurred to me, but not the multiple notebook views.

  • I stopped all the running kernels
  • I cleared the cache
  • I restarted a single notebook without refreshing the browser

Currently, it displays the hv graphs when I execute a cell. I'll continue experimenting. Maybe I can figure out how to get this to fail reliably...

ea42gh avatar Jan 03 '24 17:01 ea42gh

I forgot to mention. This bug is only with plotly and holoviews backends not with matplotlib.

LinuxIsCool avatar Jan 03 '24 18:01 LinuxIsCool

Additional observation: The solution put forward by @Hoxbro seems to have stopped working for me. However, the solution from @ea42gh is resolving the issue for me. To make it clear the following is working:

  1. Kernel Tab -> Shut Down All Kernels
  2. Close all notebooks
  3. Hard Refresh Browser
  4. Open Notebook
  5. Restart Kernel on Notebook

LinuxIsCool avatar Jan 08 '24 21:01 LinuxIsCool

We also experienced the issue here. I'm not sure if we had more of that one or more of the CORS header issue (we are not in webdev business so no-one locally is really able to debug these things), but the end result is that we have been plagued with plots disappearing all the time. Is there a way to programmatically clear those caches somehow from some Python code ? At this point we probably care a lot less about load time than just being able to see the plot.

douglas-raillard-arm avatar Mar 20 '24 10:03 douglas-raillard-arm

This all sounds incredibly frustrating. I'm taking another deep look at this today, if someone has a reproducible way to trigger these issues I'd be very grateful.

philippjfr avatar Mar 20 '24 11:03 philippjfr

I managed to reproduce it by:

  1. creating a basic notebook that just does one plot:
import holoviews as hv
hv.extension('bokeh', inline=True)
hv.Curve([1,2])
  1. Do not close the jupyter server
  2. in the same venv, force install an older bokeh (I used 3.2.0)
  3. Make a new notebook with the same code and run it in the same jupyterlab instance as the previous notebook.
  4. Plot should not show in that 2nd notebook

I found that the issue is that window.Bokeh.Panel is null. The path I hit is this line: https://github.com/holoviz/panel/blob/b36ec0cc829b3c00209886bec66c80377122b756/panel/_templates/doc_nb_js.js#L29 My current theory is that this Bokeh.versions.get(py_version) call does not initialize Bokeh.Panel properly. When I assign it the existing window.Bokeh.Panel object, I end up (unsurprisingly) with errors down the line:

Uncaught Error: could not resolve type 'panel.models.browser.BrowserInfo', which could be due to a widget or a custom model not being registered before first usage

douglas-raillard-arm avatar Mar 20 '24 12:03 douglas-raillard-arm

At some point I ran:

import panel as pn
pn.extension()

And now I can't reproduce the issue anymore, even after clearing caches and cookies.

douglas-raillard-arm avatar Mar 20 '24 14:03 douglas-raillard-arm

I just encountered this; I suspect this is a cache thing.

I'm usually working on Panel >= 1.4.0, but had to work on a pinned Panel == 1.3.8. Following these steps made it work for me.

Clear the notebook and save. Close all the notebooks. Hard refresh the browser.

ahuang11 avatar May 10 '24 06:05 ahuang11

I've run into this issue now with bokeh-3.4.0, holoviews-1.18.3, panel-1.4.2. Specifically, when opening a notebook the plots are there at first, but if I run a cell that should display a plot then nothing shows up except the TypeError: Bokeh is undefined message in the JS console. A combination of refresh and close / reopen seems to sometimes manage getting the plots visible, but this is completely impractical for the Jupyter workflow.

Downgrading to bokeh-3.3.0, holoviews-1.18.3, panel-1.4.2 has made it work again for me at the moment without the shenanigans, but that's clearly not satisfying either.

leftaroundabout avatar May 27 '24 12:05 leftaroundabout

This still occurs: https://discord.com/channels/1075331058024861767/1088157184489164831/1273669842473320579

Coderambling avatar Aug 15 '24 21:08 Coderambling

This still occurs: https://discord.com/channels/1075331058024861767/1088157184489164831/1273669842473320579

@Coderambling, yes. This issue is still open and this PR https://github.com/holoviz/hvplot/pull/1359 with a potential fix has not yet been merged. Please refrain from bumping issues with messages of this kind, they're unfortunately not very helpful and cause noise (at least everyone in this issue and the maintainers will all get a notification).

maximlt avatar Aug 16 '24 08:08 maximlt