用图获得500内部服务器错误破折号

问题描述 投票:0回答:1

我正在尝试使用python库dashplotly创建仪表板。我已经成功创建了一个静态html仪表板,但是当我尝试添加绘图图而不是纯html时,我得到了500 Internal Server Error。我的代码如下:

import dash
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objs as go
import numpy as np

app = dash.Dash()

# Creating data

np.random.seed(42)
random_x = np.random.randint(1, 100, 100)
random_y = np.random.randint(1, 100, 100)

data = [go.Trace(
    x = random_x,
    y = random_y,
    mode = 'lines'
)]

layout = go.Layout(title = 'bello')


app.lyaout = html.Div([dcc.Graph(id = 'lineplot', figure = {'data': data, 'layout': layout})])

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

[这在我尝试访问网页时输出:

raise exceptions.NoLayoutException(
dash.exceptions.NoLayoutException: The layout was `None` at the time that `run_server` was called.
Make sure to set the `layout` attribute of your application
before running the server.

非常感谢您的帮助!

python plotly plotly-dash internal-server-error
1个回答
0
投票

[我猜您已经知道了,这只是第24行的错字错误。应该是app.layout而不是app.lyaout

((与该问题无关):顺便说一句,与赋值运算符=不同,在命名参数/关键字参数中的=周围不留空格是一个好习惯。

例如

random_x = np.random.randint(1, 100, 100) // assignment OK
layout = go.Layout(title = 'bello') // named parameter KO. Should be title='bello'
© www.soinside.com 2019 - 2024. All rights reserved.