如何 运行 Jupyter notebook 中的 Bokeh 应用程序?

How to run Bokeh app in Jupyter notebook?

我想在 Jupyter notebook 中创建和 运行 散景应用程序。为了尝试,我从散景教程下载了代码

from bokeh.io import output_notebook, show
output_notebook()
from bokeh.layouts import column
from bokeh.models import TextInput, Button, Paragraph

def modify_doc(doc):

    # create some widgets
    button = Button(label="Say HI")
    input = TextInput(value="Bokeh")
    output = Paragraph()

    # add a callback to a widget
    def update():
        output.text = "Hello, " + input.value
    button.on_click(update)

    # create a layout for everything
    layout = column(button, input, output)

    # add the layout to curdoc
    doc.add_root(layout)

# In the notebook, just pass the function that defines the app to show
# You may need to supply notebook_url, e.g notebook_url="http://localhost:8889" 
show(modify_doc, notebook_url="http://localhost:8888") 

当我在 Jupyter notebook 中 运行 时,我收到以下错误消息:

ERROR:tornado.application:Uncaught exception in /ws Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\websocket.py", line 494, in _run_callback result = callback(*args, **kwargs) File "C:\Users3058850\AppData\Roaming\Python\Python36\site-packages\bokeh\server\views\ws.py", line 121, in open if self.selected_subprotocol != 'bokeh': AttributeError: 'WSHandler' object has no attribute 'selected_subprotocol'

你能帮我看看哪里出了问题吗?

如果在您的环境中看起来像,您安装了一些旧的 Tornado 版本。 tornado.websocket.WebSocketHandler.selected_subprotocol 已出现在 Tornado 5.1 中。