我想使用 Bokeh 服务器来保存我的绘图和数据,这样我就可以将我的 Bokeh 应用程序嵌入到网站中。我正在尝试重新创建Bokeh 0.12.6 文档中给出的示例:
from bokeh.client import push_session
from bokeh.embed import autoload_server
from bokeh.plotting import figure, curdoc
# figure() function auto-adds the figure to curdoc()
plot = figure()
plot.circle([1,2], [3,4])
session = push_session(curdoc())
script = autoload_server(plot, session_id=session.id)
所以我正在启动一个 Bokeh 服务器并像这样运行这个 python 程序:
bokeh serve --show animated.py
我得到的错误如下所示:
File "session.py", line 298, in push:
raise IOError("Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)") Traceback (most recent call last):
File "/Users/.../anaconda/lib/python3.5/site-packages/bokeh/application/handlers/code_runner.py", line 81, in run
exec(self._code, module.__dict__)
File "/Users/.../Documents/.../.../animated.py", line 9, in <module>
session = push_session(curdoc())
File "/Users/.../anaconda/lib/python3.5/site-packages/bokeh/client/session.py", line 86, in push_session
session.push(document)
File "/Users/.../anaconda/lib/python3.5/site-packages/bokeh/client/session.py", line 298, in push
raise IOError("Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)")
OSError: Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)
我应该如何解决这个问题?如果 autoload_server() 是完全错误的方法,那么部署 Bokeh 应用程序的其他方法是什么?