Search code examples
jupyter-notebookbokeh

bokeh not showing in jupyter notebook


I am unable to plot even the most basic of Bokeh plots in Jupyter Notebook. I had a search and can see that this was a reported problem a little over a year ago but nothing since - is it still an issue for others?

from bokeh.io import output_notebook, show
from bokeh.plotting import figure

output_notebook()

p = figure(plot_width=400, plot_height=400)

p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy", 
fill_color="orange", fill_alpha=0.5)

show(p)

I get the "BokehJS 0.12.10 successfully loaded." message, but not plot. Note that it outputs html files ok.

I've tried changing the environment variables using:

import os
os.environ['BOKEH_RESOURCES'] = 'inline'

But this has not effect either. It's bee a frustrating afternoon so any help would be appreciated!


Solution

  • My guess is that your version of the notebook is too old. There is no technical path to simultaneously supporting both the new JupyterLab and classic notebook versions older than 5.0, at all. Supporting JupyterLab is an imperative, so as of recently, Bokeh can only support classic notebook 5.0 and newer. So, you can:

    • downgrade Bokeh (<= 0.12.8), or

    • updgrade Jupyter Notebook (>= 5.0), or

    • switch to recent JupyterLab betas. You will need to install the Jupyter extension with

        jupyter labextension install jupyterlab_bokeh