散景图只是弹出一个空白窗口 [英] Bokeh plots just bring up a blank window

查看:72
本文介绍了散景图只是弹出一个空白窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我最近一直在尝试学习Bokeh,但一切进展顺利,但是突然间,每当我尝试绘制Bokeh图时,浏览器就会显示空白页面.我没有错误代码,只是空白页.这是几天前我成功用于创建绘图的程序.我什至尝试加载几个星期前制作的html绘图文件,该文件在同事计算机上工作,并得到相同的结果.我什至尝试了一种基本的示例代码,并得到了相同的空白页.

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)

从来没有想过尝试一下,但是如果您不在线,标准的散景图就可以工作吗?是否会调出外部服务器来生成图,也许现在我工作中的一些IT更改正在阻止图的生成?

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?

感谢您的帮助!

推荐答案

它不会调出外部服务器,但确实需要浏览器加载JavaScript库BokehJS.默认情况下(且受大众欢迎),BokehJS从CDN(特别是从 https://cdn.bokeh.org)远程加载. ).因此,查看配置为使用CDN资源的散景图需要活动且有效的网络连接.

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.

但是可以使用内联"资源,这意味着BokehJS库直接包含在Bokeh(python库)生成的HTML输出中.最简单的方法是设置环境变量:

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.

顺便说一句,在这种情况下,参考浏览器的JavaScript控制台会很有帮助.如果无法加载CDN资源,则会在此处看到错误.

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.

这篇关于散景图只是弹出一个空白窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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