Jupyter Dash

0.4.2 · active · verified Thu Apr 16

Jupyter Dash integrates Plotly Dash applications directly into Jupyter environments like Jupyter Notebook, JupyterLab, and Google Colab. It allows for the development and display of interactive Dash apps within cells, supporting various display modes including inline, external, and JupyterLab extensions. The current version is 0.4.2, and releases are made as needed to address compatibility with Dash and Jupyter ecosystem updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a simple interactive Dash application and display it directly within a Jupyter notebook or JupyterLab environment using `JupyterDash`. The `mode` parameter in `run_server` determines how the application is displayed (e.g., inline within the cell, or as a separate tab/window). Ensure `dash_html_components` and `dash_core_components` are also installed (`pip install dash`).

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

# Create a Dash app in a Jupyter environment
app = JupyterDash(__name__)

app.layout = html.Div([
    html.H1("JupyterDash Test"),
    dcc.Dropdown(
        id='dropdown',
        options=[
            {'label': 'New York City', 'value': 'NYC'},
            {'label': 'Montreal', 'value': 'MTL'},
            {'label': 'San Francisco', 'value': 'SF'}
        ],
        value='NYC'
    ),
    html.Div(id='output-container')
])

@app.callback(
    Output('output-container', 'children'),
    Input('dropdown', 'value')
)
def display_value(value):
    return f'You have selected "{value}"'

# Run the app. For JupyterLab/Notebook use mode="inline" or "jupyterlab"
# For Google Colab, use mode="external" or omit mode
# You might need to adjust the port if it's already in use
# For colab, 'mode="jupyterlab"' will often also work
app.run_server(mode="inline", port=8050, debug=True)

view raw JSON →