1
我想使用Bokeh服務器來保存我的情節和數據,所以我可以將我的Bokeh應用程序嵌入到網站中。我試圖重新在散景0.12.6文檔中給出的example:如何正確部署需要服務器回調的Bokeh應用程序?
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)
所以我開始一個背景虛化服務器和運行這個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應用程序的其他方法是什麼?
我使用了錯誤的autoload_server kwargs。我從此編輯過正確性。 –
快速跟進:如果我想要在個人網站上動態運行此應用程序,我會添加到Bokeh CDN的鏈接嗎?或者我會怎麼去做呢? – swetharevanur
不,Bokeh服務器應用程序始終會自動加載散景服務器本身的資源。 – bigreddot