GibbsConsulting / jupyter-plotly-dash

Jupyter notebook wrapper for plotly dash applications
GNU Affero General Public License v3.0
81 stars 12 forks source link

AttributeError: 'WrappedDash' object has no attribute 'use_dash_dispatch' #62

Closed bitcometz closed 3 years ago

bitcometz commented 3 years ago

hello,

I install jupyter-plotly-dash and run it inside the jupyter with:

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

app = JupyterDash('SimpleExample')

app.layout = html.Div([
    dcc.RadioItems(
        id='dropdown-color',
        options=[{'label': c, 'value': c.lower()}
                 for c in ['Red', 'Green', 'Blue']],
        value='red'
    ),
    html.Div(id='output-color'),
    dcc.RadioItems(
        id='dropdown-size',
        options=[{'label': i, 'value': j}
                 for i, j in [('L','large'), ('M','medium'), ('S','small')]],
        value='medium'
    ),
    html.Div(id='output-size')

])

@app.callback(
    dash.dependencies.Output('output-color', 'children'),
    [dash.dependencies.Input('dropdown-color', 'value')])
def callback_color(dropdown_value):
    return "The selected color is %s." % dropdown_value

@app.callback(
    dash.dependencies.Output('output-size', 'children'),
    [dash.dependencies.Input('dropdown-color', 'value'),
     dash.dependencies.Input('dropdown-size', 'value')])
def callback_size(dropdown_color, dropdown_size):
    return "The chosen T-shirt is a %s %s one." %(dropdown_size,
                                                  dropdown_color)

app

it only shows the texts but it keeps reporting the errors:

[IPKernelApp] ERROR | Exception in comm_msg for 5c6d476eb58e40c1b820311177395aaa
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ipykernel/comm/manager.py", line 111, in comm_msg
    comm.handle_msg(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ipykernel/comm/comm.py", line 161, in handle_msg
    self._msg_callback(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_plotly_dash/nbkernel.py", line 47, in callback
    response, mimetype = app.process_view(stem, args, app_path)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_plotly_dash/dash_wrapper.py", line 152, in process_view
    resp, rmt = func(args, app_path, view_name_parts)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_plotly_dash/dash_wrapper.py", line 178, in rv__dash_update_component
    if dapp.use_dash_dispatch():
AttributeError: 'WrappedDash' object has no attribute 'use_dash_dispatch'
[IPKernelApp] ERROR | Exception in comm_msg for 5c6d476eb58e40c1b820311177395aaa
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ipykernel/comm/manager.py", line 111, in comm_msg
    comm.handle_msg(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ipykernel/comm/comm.py", line 161, in handle_msg
    self._msg_callback(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_plotly_dash/nbkernel.py", line 47, in callback
    response, mimetype = app.process_view(stem, args, app_path)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_plotly_dash/dash_wrapper.py", line 152, in process_view
    resp, rmt = func(args, app_path, view_name_parts)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_plotly_dash/dash_wrapper.py", line 178, in rv__dash_update_component
    if dapp.use_dash_dispatch():
AttributeError: 'WrappedDash' object has no attribute 'use_dash_dispatch'
GibbsConsulting commented 3 years ago

This looks like a recent change in django-plotly-dash is not backwards compatible. Raised an issue in that project

GibbsConsulting commented 3 years ago

As of v1.6.1 of django-plotly-dash this should now be resolved.

pip install -U django-plotly-dash

should be enough to fix things.