I’m developing a little gui, and am having the issue described below. I’m not convinced this is a bug yet, so I’m putting it on community support. Happy to move it over to github if it turns out there’s a bug.
Issue
show(bkapp,notebook_url=notebook_url) does not display the app bkapp in Jupyterlab
(note that notebook_url is correctly chosen to match the url and port.)
This happens when output_notebook() has been called in advance.
However, calling
import holoviews as hv
hv.extension('bokeh')
enables the call to show to work. Calling output_notebook after hv.extension will reintroduce the problem.
> jupyter labextension list
JupyterLab v2.2.4
Known labextensions:
app dir: ~\Miniconda3\envs\py38\share\jupyter\lab
@bokeh/jupyter_bokeh v2.0.3 enabled ok
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled ok
@pyviz/jupyterlab_pyviz v1.0.4 enabled ok
jupyterlab-jupytext v1.2.1 enabled ok
running %watermark and %watermark -iv on the linked notebook (with holoviews loaded) gives
CPython 3.8.5
IPython 7.17.0
compiler : MSC v.1916 64 bit (AMD64)
system : Windows
release : 10
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
CPU cores : 12
interpreter: 64bit
yaml 5.3.1
holoviews 1.13.3
I can’t repro any problems on OSX with Bokeh 2.1.1 and either Jupyterlab 2.0.0 or 2.2.4. Can you try things on different platforms/machines to see if it is something specific to your current local system?
Thanks for the quick reply, Bryan.
Here’s the solution:
from bokeh.resources import INLINE
output_notebook(resources=INLINE)
This is required on (my organization-managed) Chrome 84.0.4147.125 on Windows 10
The evidence was in the javascript console showing
Access to script at 'https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js'
from origin 'http://localhost:8888' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
I could not fix it with any variation of trying to load the script directly in html with the crossorigin keyword.
A little googling indicates that Chrome is cracking down on cross-origin requests, so this problem may become more widespread.
Fortunately, there is no problem in the latest Firefox.
After finding the problem, I realized that running output_notebook had stalled on Loading BokehJS ... rather than showing BokehJS 2.1.1 successfully loaded, so the bug was not silent within the notebook, although I failed to recognize its import. Interestingly, the few non-app plots I tried while debugging had no-issue.
Well if you go down the rabbit hole it seems there is an ambiguity in the spec wrt to caching and origin headers. You could/should also try clearing cache, force reloading, etc.