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

时间:2018-05-01 16:18:16

标签: 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)

2 个答案:

答案 0 :(得分:1)

不确定对此问题是否明确。但是我到这里结束了,因为重命名了div id,但由于得到了相同的确切错误,但是我仍在尝试将旧的id作为我的回调函数之一的State输入。

只要将其留在这里,以防它对某人有所帮助。

答案 1 :(得分:0)

我的代码碰巧遇到此错误,升级Dash软件包有助于解决此问题。

pip install dash --upgrade

在v1.4.0之前,升级使其成为v1.9.1