运行plotly dash代码时,在chrome浏览器中加载依赖项时出错

nay*_*ant 2 python pandas plotly plotly-dash

我是情节破折号的新手,并尝试运行这个谷歌搜索的代码来理解输出。当我在 Windows cmd 提示符下运行以下代码时,执行返回 URL - http://127.0.0.1:3003 在 Chrome 浏览器中粘贴上述内容时,浏览器窗口中会显示加载依赖项时出错。请找到下面的代码。

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd


df = pd.read_excel(
    "https://github.com/chris1610/pbpython/blob/master/data/salesfunnel.xlsx?raw=True"
)

pv = pd.pivot_table(df, index=['Name'], columns=["Status"], values=['Quantity'], aggfunc=sum, fill_value=0)


trace1 = go.Bar(x=pv.index, y=pv[('Quantity', 'declined')], name='Declined')
trace2 = go.Bar(x=pv.index, y=pv[('Quantity', 'pending')], name='Pending')
trace3 = go.Bar(x=pv.index, y=pv[('Quantity', 'presented')], name='Presented')
trace4 = go.Bar(x=pv.index, y=pv[('Quantity', 'won')], name='Won')

app = dash.Dash()
app.layout = html.Div(children=[
    html.H1(children='Sales Funnel Report'),
    html.Div(children='''National Sales Funnel Report.'''),
    dcc.Graph(
        id='example-graph',
        figure={
            'data': [trace1, trace2, trace3, trace4],
            'layout':
            go.Layout(title='Order Status by Customer', barmode='stack')
        })
])
app.scripts.config.serve_locally = True
app.css.config.serve_locally = True
if __name__ == '__main__':
    app.run_server(port=3003)

if __name__ == '__main__':
    app.run_server(debug=True)
Run Code Online (Sandbox Code Playgroud)

ozg*_*ral 5

具体这个问题不太清楚。但我最终来到这里,因为我得到了同样的错误,因为我重命名了一个 div id,但我仍在尝试在我的回调函数之一中获取旧 id 作为状态输入。

把它留在这里以防它对某人有帮助。