GuillemB
GuillemB

Reputation: 621

Bokeh can't load bokeh from CDN

I'm trying to embed a plot with its data using autoload_static into a simple html page that I want to read locally on my computer. From what I make in the documenation I only need to place the .js file on the specified folder and insert the tag in the html. But firefox is giving me the next error: "failed to load library http://cdn.bokeh.org/bokeh-114a47707b567971f835c5877d2be44ea4e57fef.min.js" pl.js:21

import numpy as np
from bokeh.plotting import *
from bokeh.objects import PanTool
N = 80

x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)

pantool = PanTool(dimensions=["width", "height"])
plot = line(x,y, color="#0000FF", tools=['wheel_zoom','box_zoom', pantool],
     name="line_example")

from bokeh.resources import CDN
from bokeh.embed import autoload_static


js, tag = autoload_static(plot, CDN,"/Users/john/Desktop/Tests/js/pl.js")

file = open("/Users/john/Desktop/Tests/js", "w")    
file.write(js)
file.close()

print(tag)

And the html page:

<!DOCTYPE html>
<html>
<body>

<h1>
Hello World
</h1>

<p><script
    src="/Users/john/Desktop/Tests/js/pl.js"
    id="836fbd4f-68b5-4cdf-8a56-047c2a22af2a"
    async="true"
    data-bokeh-data="static"
    data-bokeh-modelid="line_example"
    data-bokeh-modeltype="Plot"
    data-bokeh-loglevel="info"
></script></p>

</body>
</html>

Upvotes: 2

Views: 2067

Answers (1)

bigreddot
bigreddot

Reputation: 34568

How did you install Bokeh? It looks like you have installed from a GitHub checkout? (That is not a standard Bokeh version number, it looks like a GH hash). The standard resources.CDN resource object tries to use the current bokeh version to determine the version of BokehJS to load from CDN. Only official released versions are uploaded to CDN, so Resources.CDN is not going to be useful with a GH source install. You will have to create your own Resource object and pass in the version you want, something like:

myCDN = Resources(mode="cdn", version="0.6.1")

and then pass that to autoload_script.

However, there is currently no guarantee made that new, current GH master works with previously released BokehJS versions. So there is no guarantee that this would work either, in general. My strong recommendation is to stick with official Bokeh releases.

If this is an official Bokeh release (conda or PyPI package) then it is a serious packaging bug, please file a report at https://github.com/bokeh/bokeh/issues with as much detail as possible.

Upvotes: 3

Related Questions