![](/img/trans.png)
[英]Internal 500 error on Elastic Beanstalk with plotly dash app
[英]Getting a 500 Internal server error dash with plotly
我正在嘗試使用 python 庫dash
和plotly
創建一個儀表板。 我已經成功創建了一個 static html 儀表板,但是當我嘗試添加一個 plotly 圖而不是普通的 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.
任何幫助是極大的贊賞!
我想你已經想通了,這只是第 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'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.