首页 > 解决方案 > Python dash 给了我一个“错误加载布局”我该如何解决这个问题?

问题描述

嘿,我是 Python Dash 的新手,我遵循了https://dash.plot.ly/installation教程。

首先,我在我的 cmd shell 中安装了所有带有 pip 的库。

之后,我创建了 app.py 文件并添加了以下代码:

import dash
import dash_core_components as dcc
import dash_html_components as html

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

到目前为止还没有错误。当我启动服务器并转到http://127.0.0.1:8050时,网页给了我一个错误:“加载布局错误”。

我试图通过所有其他报告来寻求帮助,但我仍然找不到答案。

我希望有人可以帮助我。

非常感谢!

标签: pythonplotly-dash

解决方案


我成功地运行了这个没有问题,所以我认为这是一个你的模块不完整的问题。尝试通过 pip 或 conda 重新安装所有底层模块(dash、dcc 和 html),看看是否能解决问题。


推荐阅读