I am trying to get the first Dash example from https://dash.plotly.com/basic-callbacks running in a Jupyter Notebook with Jupyter Dash and the app runs fine as a standalone application, but errors out when implemented in the notebook and I can't figure this out. I get
TypeError: an integer is required (got type NoneType)
when I try to run the notebook.
from jupyter_dash import JupyterDash
import dash_html_components as html
import dash_core_components as dcc
import dash
from dash.dependencies import Input, Output
app = JupyterDash(__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(mode="external")
The main difference is with the imports and app.run_server()
In pycharm I just had from dash import Dash, html, dcc, Input, Output
and app.run_server(debug=True)
. From what I've researched there's some issues with versioning and the updates I made should have fixed the issues and I can't seem to find anything about the error I am getting.
EDIT: Traceback from error
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\1/ipykernel_31316/4067692673.py in <module>
28
29 if __name__ == '__main__':
---> 30 app.run_server(mode="external")
~\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_dash\jupyter_app.py in run_server(self, mode, width, height, inline_exceptions, **kwargs)
220 self._terminate_server_for_port(host, port)
221
--> 222 # Configure pathname prefix
223 requests_pathname_prefix = self.config.get('requests_pathname_prefix', None)
224 if self._input_pathname_prefix is None:
~\AppData\Local\Programs\Python\Python39\lib\site-packages\jupyter_dash\_stoppable_thread.py in kill(self)
TypeError: an integer is required (got type NoneType)