我已经安装了bokeh并从官方页面(http://bokeh.pydata.org/en/latest/docs/user_guide/server.html)下载了myapp.py,如下所示。
# myapp.py
from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
# create a plot and style its properties
p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None
# add a text renderer to our plot (no data yet)
r = p.text(x=[], y=[], text=[], text_color=[], text_font_size="20pt",
text_baseline="middle", text_align="center")
i = 0
ds = r.data_source
# create a callback that will add a number in a random location
def callback():
global i
# BEST PRACTICE --- update .data in one step with a new dict
new_data = dict()
new_data['x'] = ds.data['x'] + [random()*70 + 15]
new_data['y'] = ds.data['y'] + [random()*70 + 15]
new_data['text_color'] = ds.data['text_color'] + [RdYlBu3[i%3]]
new_data['text'] = ds.data['text'] + [str(i)]
ds.data = new_data
i = i + 1
# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
# put the button and plot in a layout and add to the document
curdoc().add_root(column(button, p))
在终端中,我执行:
bokeh serve --show myapp.py
我明白了:
2017-04-17 13:24:50,576 Starting Bokeh server version 0.12.5
2017-04-17 13:24:50,581 Starting Bokeh server on port 5006 with applications at paths ['/myapp']
2017-04-17 13:24:50,581 Starting Bokeh server with process id: 700
我的浏览器(尝试使用Safari和Chrome)然后弹出http://localhost:5006/myapp的新标签页,但该页面无法加载。它在进度条上大约停留在10%左右,并且永远不会从"等待本地主机..."。我已经安装了散景网站上列出的依赖项。我错过了什么?
顺便说一句,我正在运行OS X 10.12.4。我也尝试过在Windows机器上遇到完全相同的问题。在我的网络浏览器的控制台中没有任何显示,它只是不断地等待127.0.0.1"。我看到一个" 302 GET"如果我关闭浏览器并尝试重新打开该页面,请在我的终端中提出请求。
答案 0 :(得分:13)
我希望你们都能解决这个问题:
Bokeh Server is incompatible with tornado=4.5
Tornado 4.5(几天前发布)进行了一项更改,导致Bokeh服务器无法正常运行。对此的修复是在master中,将在下一个0.12.6
版本中。但该修复程序也可在最新的开发版中使用。您的直接选择是: