bokeh / jupyter_bokeh

An extension for rendering Bokeh content in JupyterLab notebooks
BSD 3-Clause "New" or "Revised" License
251 stars 48 forks source link

Doesn't seem to work with `jupyter notebook` #150

Open cpsievert opened 2 years ago

cpsievert commented 2 years ago

After doing pip install jupyter_bokeh, jupyter notebook, then running the following in a notebook cell:

from bokeh.plotting import figure
from jupyter_bokeh import BokehModel

x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
p = figure(title="Simple line example", x_axis_label="x", y_axis_label="y")
p.line(x, y, legend_label="Temp.", line_width=2)
BokehModel(p)

I get no output and the following JS errors:

Screen Shot 2022-03-22 at 2 47 13 PM

Am I doing something wrong? I have a feeling this might be related to the fact that the notebook extension config is pointing to a seemingly non-existant nbextension/static (should it be nbextension instead)?

https://github.com/bokeh/jupyter_bokeh/blob/4010f6ce88f37afeadc2118b5c262d9cd0f19855/jupyter_bokeh/__init__.py#L22

bryevdv commented 2 years ago

@cpsievert @philippjfr is probably the best person to speculate on this but I will go ahead and say up front that complete version information is needed for all the relevant packages.

Edit: also, just to be clear, AFAIK the jupyter_bokeh is only needed (and only works with) JupyterLab. Classic notebook still uses the old historical "publish JS to output cells" approach that was always used with classic notebook, and as a result is limited to the things that have historically been supported that way. Any specialized features of the jupyter_bokeh extension itself (such as BokehModel) would not work with classic notebook, in case you are using classic notebook (why it is always important to specify exact version information in all issues)

philippjfr commented 2 years ago

I believe what's missing here is running bokeh.io.output_notebook(). We can probably document this better and at least issue a browser console warning if bokeh hasnt been loaded.

bryevdv commented 2 years ago

@philippjfr can you clarify/confirm re: classic notebook expectations?

cpsievert commented 2 years ago

Ah, I see, that fixes it, thanks! A mention on the README would be helpful

bryevdv commented 2 years ago

@cpsievert FYI the docs for everything Bokeh related are consolidated on the main docs site

https://docs.bokeh.org/en/latest/docs/user_guide/jupyter.html