1

i'm trying to learn dash i'm at the third tutorial but it raise this error whenever i run the file(python app.py)

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

this is the code i'm running :

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)

please what is wrong with the code?! even i tried to copy and paste the code still raise the same error thank you ..

versions

python = 3.6

dash=1.7.0

dash-core-components=1.6.0

dash-html-components=1.0.2

2
  • 3
    coralvanda gave the solution to fixing the error in the accepted answer, but if possible, you should update your dash version (current is 1.20.0). The code you posted runs without issues in 1.20.0. If you continue the tutorial using the out-of-date 1.7.0, you'll probably encounter more problems. Commented May 5, 2021 at 6:43
  • +1 for the answer of @Michel. This problem has been mentioned here as well. Simply updating Dash via pip install -U dash should suffice. The accepted answer could be misleading. Commented Sep 27, 2021 at 18:18

1 Answer 1

3

You need to wrap your inputs in a list, like this:

@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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.