user1340654
user1340654

Reputation: 425

Bokeh plot not showing in Jupyter. Only says "Loading BokehJS ..."

Bokeh used to work fine for me. It just stopped working this week. I get the same behavior on FireFox and Chrome on my mac. Here's an example of the problem. This is my jupyter code:

import pandas as pd
import datetime
import matplotlib.pyplot as plt
import itertools as itt
import bokeh.plotting as bk
bk.output_notebook()

xs = [0,1,2,3,4,5]
ys = [x**2 for x in xs]

p = bk.figure()

p.line(xs, ys, line_width=2)
p.circle(xs,ys)
bk.show(p)

The only output is "Loading BokehJS ..."

Upvotes: 4

Views: 10257

Answers (2)

Hafez Ahmad
Hafez Ahmad

Reputation: 185

You can follow this, worked for me.

from bokeh.resources import INLINE
import bokeh.io

bokeh.io.output_notebook(INLINE)

Upvotes: 7

bigreddot
bigreddot

Reputation: 34568

Bokeh plots rely on 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

before you run your script or the notebook server. There are other ways to specify resources, though, too. For more details see the documentation.

Upvotes: 9

Related Questions