hvplot does not render in code cells, panel widgets
Thanks for contacting us! Please read and follow these instructions carefully, then delete this introductory text to keep your issue easy to read. Note that the issue tracker is NOT the place for usage questions and technical assistance; post those at Discourse instead. Issues without the required information below may be closed immediately.
ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc) hvplot 0.9.0 bokeh 3.3.2 panel 1.3.4 holoviews 1.18.1 jupyterlab 4.0.9
Description of expected behavior and the observed behavior
This happened after update of bokeh from 3.3.1. There are two issues:
- When the code below is run in code cell, it does not display. The same code works when typed in the associated console. However, when I close and reopen the notebook, the image is shown in the code cell.
- Another problem is that the select widget does not work (when displayed in console): the items can be selected, but the image does not change.
I tried both firefox and chromium browsers. The javascript console log output is shown below.
Complete, minimal, self-contained example code that reproduces the issue
# code goes here between backticks
import panel as pn
import hvplot.pandas # noqa
from bokeh.sampledata.iris import flowers
flowers.hvplot.bivariate(x='sepal_width', y='sepal_length', width=600,
groupby='species')
Stack traceback and/or browser JavaScript console output
Kernel not found, could not register comm target 88e9030be98c4772a287ba219fc9b1c9
30.142e2e0fa2b610ad434f.js?v=142e2e0fa2b610ad434f:1
Kernel not found, could not connect to comm target 8b26b18e4d574fe88e11c2a944906088
jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1
Uncaught Error: Comms are disabled on this kernel connection
at y.createComm (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1238060)
at Object.connectToComm (30.142e2e0fa2b610ad434f.js?v=142e2e0fa2b610ad434f:1:9054)
at JupyterCommManager.get_client_comm (<anonymous>:51:50)
at d.initialize (panel.min.js:54:833)
at d.finalize (bokeh-3.3.2.min.js:179:4582)
at p.decode (bokeh-3.3.2.min.js:212:805)
at S.from_json (bokeh-3.3.2.min.js:165:6273)
at t.embed_items_notebook (bokeh-3.3.2.min.js:231:2268)
at embed_document (<anonymous>:11:17)
at <anonymous>:40:5
Screenshots or screencasts of the bug in action
- [ ] I may be interested in making a pull request to address this
I did more tests. It is not bokeh, there is something going on. I duplicated the code below in two identical notebooks.
import panel as pn
import hvplot.pandas # noqa
from bokeh.sampledata.iris import flowers
flowers.hvplot.bivariate(x='sepal_width', y='sepal_length', width=600,
groupby='species')
I had a case when, after opening both, one of them worked, the other did not display the image (there were several messages Kernel not found, could not connect to comm target in JavaScript console). However, when I changed JupyterLab kernel to a different one, then changed it back, the code started working again. My hunch is an issue with pyviz_comms.
Hi @yt87, if you have hvPlot installed in an environment that is not your JupyterLab environment, you also need to install pyviz_comms in the JupyterLab environment. Panel just recently merged some clearer instructions on this topic https://github.com/holoviz/panel/pull/5980, the same should be done for hvPlot.
But please, could you make sure that it all works as expected if you install pyviz_comms in the environment that contains JupyterLab?
I did more testing. My enviroments:
jupyter: bokeh 3.3.2, pyviz_comms 3.3.0, panel 1.3.4
icec: same as above
test: same
test2: bokeh 3.3.1, rest same as above.
I use jupyter to run jupyterlab. The code works in icec and test. When I switch kernels I do see warnings in the java console, but those seem to be harmless:
TypeError: Cannot read properties of undefined (reading 'widget')
at isReady (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1061486)
at jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:878686
at b (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:878780)
at P.onKernelChanged (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1060643)
at m (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1656463)
at Object.l [as emit] (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1656139)
at a.emit (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1653976)
at b._onKernelChanged (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:132362)
at m (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1656463)
at Object.l [as emit] (jlab_core.a61821d8a2a9c35d7996.js?v=a61821d8a2a9c35d7996:1:1656139)
Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early
It does not work in test2, the error is
Panel: ERROR: Unable to run Panel code because Bokeh or Panel library is missing
So, it seems that bokeh versions must match exactly. Is there a section in the documentation that would tell me which components belong to the jupyter environment, and which should go to the client side? I looked at https://docs.bokeh.org/en/latest/docs/first_steps/installation.html and https://panel.holoviz.org/getting_started/installation.html, the scenario of separate environmens is not covered.
Hi @yt87, you should not have to deal with installing client-side versions of Bokeh, the Python and client versions should be the same.
I've been able to reproduce (part of?) your problem, by:
- creating a
test1env withbokeh 3.3.2and atest2env withbokeh 3.3.1 - running JupyterLab from another environment with the latest pyviz_comms version
- running the snippet in a new notebook from
test1 - running the snippet in another notebook from
test2
In which case, in the second notebook, the plot isn't rendered at all. @philippjfr do you happen to know if that is a fundamental limitation of Bokeh in JupyterLab, i.e. that there can't be multiple versions of Bokeh loaded over multiple notebooks? Or is this a bug (potentially a very hard one to fix)?
For what it's worth @yt87, Jupyter Notebook (not Lab) doesn't suffer from the same issue, each notebook being in its own browser tab helps avoiding this kind of issue.
In which case, in the second notebook, the plot isn't rendered at all. @philippjfr do you happen to know if that is a fundamental limitation of Bokeh in JupyterLab, i.e. that there can't be multiple versions of Bokeh loaded over multiple notebooks? Or is this a bug (potentially a very hard one to fix)?
In recent versions of Panel I started adding support for loading multiple versions of Bokeh and allowing users to switch between them. If this is not working right, that's to be considered a Panel bug at this point.