输入参数“input.value”必须是“dash.dependencies.Input”的列表或元组。短跑

The input argument `input.value` must be a list or tuple of `dash.dependencies.Input`s. dash

我正在尝试学习破折号我在 third tutorial 但是每当我 运行 文件时它都会引发此错误(python app.py)

dash.exceptions.IncorrectTypeException: The input argument input.value must be a list or tuple of dash.dependencies.Inputs.

这是我运行宁的代码:

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

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

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

app.layout = html.Div([
   html.H6("Change the value in the text box to see callbacks in action!"),
   html.Div(["Input: ",
          dcc.Input(id='input', value='initial value', type='text')]),
   html.Br(),
   html.Div(id='output'),

])


@app.callback(
    Output(component_id='output', component_property='children'),
    Input(component_id='input', component_property='value')
)
def update_output_div(input_value):
    return 'Output: {}'.format(input_value)


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

请问代码有什么问题?!即使我试图复制并粘贴代码仍然会引发相同的错误 谢谢..

版本

python = 3.6

破折号=1.7.0

dash-核心组件=1.6.0

破折号-html-组件=1.0.2

您需要将您的输入包装在一个列表中,如下所示:

@app.callback(
    Output(component_id='output', component_property='children'),
    [Input(component_id='input', component_property='value')]
)
def update_output_div(input_value):
    return 'Output: {}'.format(input_value)