✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Error loading dependencies- Buttons with multiple states

I’m having trouble with this one callback, which usually returns “Error loading dependencies” despite the function working perfectly when isolated in a separate cell. I am new to Dash, but under the impression that “Error loading dependencies” only came up when the number of inputs/outputs in the callback and the function do not match.

In summary, I want to create a hidden Div that stores an index from a dataframe, then return that row’s other variables later. Any ideas to update this dynamically??

In the DOM:

In callbacks:

@app.callback([Output(‘sample-index’, ‘children’)],
[Input(‘generate-button’, ‘n_clicks’)],
[State(‘first-dropdown’, ‘value’),
State(‘SliderA’, ‘value’),
State(‘second-dropdown’, ‘value’),
State(‘SliderB’, ‘value’),
State(‘third-dropdown’, ‘value’),
State(‘mini-dropdown’, ‘value’)]
def find_sample(n_clicks, feat1, val1, feat2, val2, feat3, val3):
if n_clicks is None:
return “Choose your index”
#Find 1000 indices closest to specified feature 1 value
#Narrow down options to 100 with values closest to 2nd feature value
#Narrow to options with categorical match
#Check whether categorical variable match was found
if len(final)==1:
return [final[‘index’]],
#Else return best combo of first two variables
return [second_search.iloc[0][‘index’]]

Someone over in the #dash forum should be able to help you out.