Black Lives Matter. Please consider donating to Black Girls Code today.

Wrong dash-core-components gets invoked when importing layout from another file

Following the multi-page/multi-file example from the docs (https://dash.plot.ly/urls), I am getting this error trying to instantiate a dcc.Input

TypeError: __init__() takes exactly 1 argument (4 given)

I do not get this error when the same code is all in one file

Here is what I’m trying to do. Running “python index.py”, this error happens at the first dcc.Input in apps/app_1.py

app.py

import dash

app = dash.Dash()

index.py

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

from app import app
from apps import app_1

app.layout = html.Div([
    dcc.Location(id="url", refresh=False),
    dcc.Link("App 1", href="/app-1"),
    html.Div(id="page-content")
])

@app.callback(
    Output("page-content", "children"),
    [Input("url", "pathname")]
)
def display_page(pathname):
    if pathname == "app-1":
        return app_1.layout

if __name__ == "__main__":
    app.run_server(debug=True)

apps/app_1.py

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

from app import app

import datetime as dt

layout = html.Div([
    html.H3("App 1"),
    dcc.Input("begindate-input", type="Date", value=dt.date.today() - dt.timedelta(days=30)),
    dcc.Input("enddate-input", type="Date", value=dt.date.today()),
])

Actually the reason appears to be the missing “id” as the first argument

e.g.

dcc.Input(id="enddate-input", type="Date", value=dt.date.today()),

vs

dcc.Input("enddate-input", type="Date", value=dt.date.today()),

Please delete