Error when importing Input

Hello!
When importing Input from the Dash library in python (from dash import Input) I am getting the following error:

ImportError: cannot import name 'Input' from 'dash' 

I made sure I have the newest version of Dash installed.

Thanks in advance,
YW

Hi yaniv_w

How you import your libraries?. Here is a example.

https://dash.plotly.com/basic-callbacks

from dash import Dash, dcc, html, Input, Output

app = Dash(__name__)

app.layout = html.Div([
    html.H6("Change the value in the text box to see callbacks in action!"),
    html.Div([
        "Input: ",
        dcc.Input(id='my-input', value='initial value', type='text')
    ]),
    html.Br(),
    html.Div(id='my-output'),

])


@app.callback(
    Output(component_id='my-output', component_property='children'),
    Input(component_id='my-input', component_property='value')
)
def update_output_div(input_value):
    return f'Output: {input_value}'


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

image

hey @SamuelVT ,
thans for the quick replay!
I am importing the library in the common way:

from dash import Input

with no further lines besides this one, when I run it I get that error.

Hi yaniv_w

  • Check your version against the latest versions announced in this forum or in the CHANGELOG. If you are on an older version, try upgrading.

  • You can find these versions by doing: print(dash.__version__) , print(dcc.__version__) , print(html.__version__) , print(dash_table.__version__) , print(plotly.__version__)

HI @SamuelVT

on one hand, when I run the print lines in this order, I get this output:
1.17.0
1.13.0
1.1.1
4.11.0
5.6.0

meaning that my notebook uses dash version 1.17.0
on the other hand, I have the version 2.0.1 installed.
how come?

Hi yaniv_w

Plotly with Jupyter Notebook for Windows

  • Open command prompt and cd into your main directory
  • Create directory where you want to develop your project/app, by typing: mkdir foldername
  • cd into the new folder
  • Create a virtual environment, by typing: py -m venv EnvironmentName
  • Activate your new environment, by typing: .\EnvironmentName\Scripts\activate
  • Install required libraries into activated virtual environment:
        pip install pandas
        pip install dash
        pip install notebook
  • Check the full list of libraries you just installed, by typing: pip list

dash 2.1.0
dash-core-components 2.0.0
pandas 1.3.5
etc…

Start Jupyterlab by typing: jupyter notebook

  • Run your app

Here is a example:

from dash import Dash, dcc, html, Input, Output

app = Dash(__name__)

app.layout = html.Div([
    html.H6("Change the value in the text box to see callbacks in action!"),
    html.Div([
        "Input: ",
        dcc.Input(id='my-input', value='initial value', type='text')
    ]),
    html.Br(),
    html.Div(id='my-output'),

])


@app.callback(
    Output(component_id='my-output', component_property='children'),
    Input(component_id='my-input', component_property='value')
)
def update_output_div(input_value):
    return f'Output: {input_value}'


if __name__ == '__main__':
    app.run_server(debug=False, use_reloader=False) 
2 Likes