Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bokeh plots just bring up a blank window

Tags:

python

bokeh

So I've been trying to learn Bokeh recently and everything was going well but suddenly whenever I try and make a Bokeh plot the browser just shows a blank page. I get no error codes just the blank page. This is with programs that I was successfully using to create plots just a couple days ago. I even tried loading a html plot file I'd made a few weeks ago that had worked on co-workers computers and got the same result. I even tried one of the basic example code and got the same blank page.

from bokeh.plotting import figure, output_file, show

p = figure(title="line", plot_width=300, plot_height=300)
p.line(x=[1, 2, 3, 4, 5], y=[6, 7, 2, 4, 5])

show(p)

Never thought to try it but do standard Bokeh plots work if you are not online? Does it callout to an external server to generate the plots and maybe now some IT changes at my work are preventing the plots from being generated?

Thanks for any help!

like image 548
BikeControl Avatar asked Jan 25 '17 16:01

BikeControl


1 Answers

It does not call out to an external server, but it does require the browser to load a JavaScript library, BokehJS. By default (and by popular demand) BokehJS is loaded remotely from a CDN (specifically, from https://cdn.bokeh.org). Accordingly, viewing a Bokeh plot that is configured to use CDN resource requires an active and working network connection.

But it's possible to use "inline" resources, which means the BokehJS library is included directly in the HTML output that Bokeh (the python library) generates. The easiest way to to do this is to set the environment variable:

BOKEH_RESOURCES=inline

There are other ways to specify resources, though, too. For more details see the documentation.


As an aside, in a situation like this it is helpful to consult your browser's JavaScript console. If the CDN resources can't be loaded, you will see the error there.

like image 155
bigreddot Avatar answered Oct 26 '22 16:10

bigreddot