I have a notebook in which I want to display some interactive figures using plotly, then construct a dashboard within the notebook using JupyterDash. The following code works fine on my machine:
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
df = pd.DataFrame({'category':['a','b','c'],
'value':[1,2,3]})
px.bar(df, x='category', y='value')
import dash
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = JupyterDash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(
[
html.H1("Test dashboard")
]
)
if __name__ == '__main__':
app.run_server(mode='inline', debug=True, port=8060)
However, when I split this code across two cells, as follows:
Cell 1
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
df = pd.DataFrame({'category':['a','b','c'],
'value':[1,2,3]})
px.bar(df, x='category', y='value')
Cell 2
import dash
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = JupyterDash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(
[
html.H1("Test dashboard")
]
)
if __name__ == '__main__':
app.run_server(mode='inline', debug=True, port=8060)
Then I receive the following error:
AttributeError: module 'google.colab.output' has no attribute 'serve_kernel_port_as_iframe'
The only thing that is different between the two scenarios is that in the second the code is split into two cells. However, in scenario 2, the dashboard displays normally if I comment out the call to px.bar
in the first cell.
What I've tried:
- Many different port numbers
- Updating various packages to the latest versions, including plotly, dash, JupyterDash, and google.colab
Much appreciation for any insight you can provide