Bokeh无法从CDN加载散景 [英] Bokeh can't load bokeh from CDN

查看:86
本文介绍了Bokeh无法从CDN加载散景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用autoload_static将其数据嵌入到我想要在我的计算机上本地读取的简单html页面中。根据我在文档中的内容,我只需要将.js文件放在指定的文件夹中,然后在html中插入标记。
但是firefox给了我下一个错误:
无法加载库 http://cdn.pydata.org/bokeh-114a47707b567971f835c5877d2be44ea4e57fef.min.js pl.js:21

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.pydata.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)

和html页面:

<!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>


推荐答案

你是如何安装Bokeh的?看起来你已经从GitHub结帐安装了? (这不是标准的Bokeh版本号,它看起来像GH哈希)。标准 resources.CDN 资源对象尝试使用当前散景版本来确定要从CDN加载的BokehJS的版本。只有官方发布的版本上传到CDN,因此 Resources.CDN 对于GH源安装不会有用。您必须创建自己的资源对象并传入所需的版本,例如:

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")

然后将其传递给 autoload_script

然而,目前没有保证新的当前GH大师与以前发布的BokehJS版本一起使用。因此,一般而言,无法保证这也能奏效。我的强烈建议是坚持官方的Bokeh版本。

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.

如果这是官方的Bokeh版本(conda或PyPI包),那么这是一个严重的包装错误,请在 https://github.com/bokeh/bokeh/issues 尽可能详细。

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.

这篇关于Bokeh无法从CDN加载散景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆