【问题标题】:How to run the dashboard in Jupyter Notebook?如何在 Jupyter Notebook 中运行仪表板?
【发布时间】:2021-04-04 17:17:14
【问题描述】:

我开始在 Jupyter Notebook 中学习仪表板并遇到问题,我无法启动它并访问已创建的链接。我搜索了一些文档,但没有找到答案,代码:


import dash_core_components as dcc

import dash_html_components as html

import pandas as pd

app = dash.Dash()

app.Layout = html.Div(children = [html.H1("Hello")])

app.run_server()

运行最后一行后,我收到以下消息:

Running on http://127.0.0.1:8050/
Debugger PIN: 872-718-697
 * Serving Flask app "__main__" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

如果我从消息的第一行访问链接,则页面未加载

【问题讨论】:

  • 显示您正在尝试从 Jupyter 运行 Flask 应用程序。 Jupyter 使用 Tornado 网络服务器,Jupyter 中的小部件/仪表板/扩展是静态 Angular 应用程序

标签: python jupyter-notebook dashboard


【解决方案1】:

在jupyterLab环境下,通过安装模块,执行结果会显示为单元格结果。安装说明可以在here 找到。推荐使用 jupyterlab。

import dash
import dash_core_components as dcc
import dash_html_components as html
from jupyter_dash import JupyterDash 
import pandas as pd

# app = dash.Dash()
app = JupyterDash(__name__)

app.layout = html.Div(children=[html.H1(children="Hello")])

app.run_server(mode='inline') # JupyterDash mode='inline'

【讨论】:

    【解决方案2】:

    您的App.layout 中有错误,您使用的是大写的app.Layout 但它必须是app.layout,此代码将起作用:

    import dash_core_components as dcc
    import dash
    import dash_html_components as html
    
    import pandas as pd
        
    app = dash.Dash()
        
    app.layout = html.Div(
                        children=[
                            html.H1(children='Hello Dash')
                        ]
                    )
    app.run_server()
    

    【讨论】:

      猜你喜欢
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 2017-08-30
      • 1970-01-01
      • 2022-01-11
      • 2020-10-23
      • 1970-01-01
      • 2018-12-02
      相关资源
      最近更新 更多