Description
Here is a minimal example after doing some trial and error to pin it down:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
def generate_inputs():
in_a_lab = html.Label('input a')
in_a = dcc.Input(type='number',
value=1)
in_b = [html.Label(html.Strong('input b')),
dcc.Input(type='number', value=1)]
inputs = [in_a_lab, in_a]
# uncomment this line to cause error
# inputs = [in_a_lab, in_a, in_b]
return inputs
app = dash.Dash()
app.layout = html.Div([
# switch the comment on these lines to cause an error
html.Div(generate_inputs())
# generate_inputs()
]) # app.layout
if __name__ == '__main__':
app.run_server(debug=True)
I started on the path of python3
, but ran into some dependency hell on Ubuntu 16.04, so I reinstalled with python2
. This created what I believe to be some actual dependency issues around urllib3
and chardet
. I was getting dependency warnings about the wrong versions on the command line when I would do python2 app.py
.
With those solved, the command line looked fine, but I'd get this in the browser:
I was in the process of building some ui elements and doing them in pairs, with a label and then matching input. Then I wanted to switch to a list of the label and pair together. I realized I was sending back a nested list (the above would generated something like [in_a_lab, in_a, [in_b_lab, in_b]]
). So, that was a definite issue, but I wouldn't expect the result to be error loading dependencies
.
On accident I found that without wrapping the function return in html.Div()
I'm also getting the same error.
This is probably an issue on my part with something I don't understand about dash
(totally likely; I'm all of 2-3 hours into playing with it). That said, if this is isn't really a "dependency error," might there be room improving the error message? From what I'm seeing, this strikes me as more of a syntax error, or something like "expected blah object, got blah instead"?
Thanks for taking a look.