Python 输入参数'input.value'必须是'dash.dependencies.input'的列表或元组。猛冲

Python 输入参数'input.value'必须是'dash.dependencies.input'的列表或元组。猛冲,python,plotly-dash,Python,Plotly Dash,我正在尝试学习dash,但每当我运行文件(python app.py)时,它都会引发此错误 dash.exceptions.IncorrectTypeException:输入参数input.value必须是dash.dependencies.inputs的列表或元组 这是我正在运行的代码: import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencie

我正在尝试学习dash,但每当我运行文件(python app.py)时,它都会引发此错误

dash.exceptions.IncorrectTypeException:输入参数
input.value
必须是
dash.dependencies.input
s的列表或元组

这是我正在运行的代码:

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

仪表板核心部件=1.6.0


dash html components=1.0.2

您需要将输入内容包装在列表中,如下所示:

@app.callback(
输出(组件id='Output',组件属性='children'),
[输入(组件id='Input',组件属性='value')]
)
def update_output_div(输入值):
返回“输出:{}”。格式(输入值)

coralvanda给出了修复已接受答案中错误的解决方案,但如果可能,您应该更新dash版本(当前版本为1.20.0)。您发布的代码在1.20.0中运行时没有问题。如果您使用过时的1.7.0继续学习本教程,您可能会遇到更多问题。