The callback... is a multi-output. Expected the output type to be a list or tuple but got:

app.layout = html.Div([
html.Div([
html.Div([
dcc.Dropdown(id=‘campusdropdown’,
options=[
{‘label’: ‘PKD’, ‘value’: ‘PARA’},
{‘label’: ‘BBSR’, ‘value’: ‘BHUVA’}
],
value=‘PARA’,
multi=False,
),
],className=‘six columns’),

],className='row'),
html.Div([
    html.Div([
        dcc.Graph(id='piechart'),
    ],className='six columns'),

],className='row')

])
######################################################################
@app.callback(
[Output(‘piechart’, ‘figure’)],
[Input(‘campusdropdown’, ‘value’)]
)
def update_data(campusdropval):
print(campusdropval)
print(dff)

df = px.data.tips()

pie_chart=px.pie(df, values=‘tip’, names=‘day’)

pie_chart=px.pie(
        data_frame=dff,
        names="Programme",
        values="Amount Pending",
        labels={'Programme':'Programme'}
        )


return (pie_chart)

if name == ‘main’:
app.run_server(debug=False,use_reloader=False)


its hard to me to findout whats wrong here

i am getting this type of error


2020-06-09 22:01:30,738] ERROR in app: Exception on /_dash-update-component [POST]
Traceback (most recent call last):
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”, line 2447, in wsgi_app
response = self.full_dispatch_request()
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”, line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”, line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_compat.py”, line 39, in reraise
raise value
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”, line 1950, in full_dispatch_request
rv = self.dispatch_request()
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”, line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\dash\dash.py”, line 1032, in dispatch
response.set_data(func(*args, outputs_list=outputs_list))
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\dash\dash.py”, line 977, in add_context
_validate.validate_multi_return(output_spec, output_value, callback_id)
File “C:\Users\naveen\AppData\Local\Programs\Python\Python36\lib\site-packages\dash_validate.py”, line 116, in validate_multi_return
callback_id, repr(output_value)
dash.exceptions.InvalidCallbackReturnValue: The callback …piechart.figure… is a multi-output.
Expected the output type to be a list or tuple but got:
Figure({
‘data’: [{‘domain’: {‘x’: [0.0, 1.0], ‘y’: [0.0, 1.0]},
‘hovertemplate’: ‘Programme=%{label}
Amount Pending=%{value}’,
‘labels’: array([‘B.TECH. AG.’, ‘B.TECH.Dairy’, ‘BBA’], dtype=object),
‘legendgroup’: ‘’,
‘name’: ‘’,
‘showlegend’: True,
‘type’: ‘pie’,
‘values’: array([8034857, 190000, 2389383], dtype=int64)}],
‘layout’: {‘legend’: {‘tracegroupgap’: 0}, ‘margin’: {‘t’: 60}, ‘template’: ‘…’}
}).
127.0.0.1 - - [09/Jun/2020 22:01:30] “e[35me[1mPOST /_dash-update-component HTTP/1.1e[0m” 500 -

Hi @NaveenKumar
Welcome to Dash, the main error message is:
“The callback …piechart.figure… is a multi-output. Expected the output type to be a list or tuple but got:”

And this is because your Output in the callback decorator is inside a list.

[Output(‘piechart’, ‘figure’)],

It should only be inside a list if there are multiple Outputs. You have only one, so take out the list brackets.

Side note: it’s very hard to read your code and the post. Refer to How to get Your Questions answered on the Plotly Forum to learn to write cleaner posts, which will help you get more replys.

4 Likes