Search code examples
pythonjupyter-notebookplotlygoogle-colaboratoryplotly-dash

Problems running Dash in Jupyter notebook


I just copy and paste the first batch of code from : https://dash.plot.ly/getting-started to my Jupyter notebook and this what I am getting:

Running on http://127.0.0.1:8050/ Debugger PIN: 124-434-522 Debugger PIN: 124-434-522 Debugger PIN: 124-434-522 Debugger PIN: 124-434-522 * Serving Flask app "__main__" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on An exception has occurred, use %tb to see the full traceback. SystemExit: 1

Any help will be more than appreciated.

(Updated comment) I have aslo tried google colab. Unfortunately it doesn't work on it neither. this is what I am getting:

# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

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

ModuleNotFoundError Traceback (most recent call last) in () ----> 1 import dash 2 import dash_core_components as dcc 3 import dash_html_components as html 4 5 external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

ModuleNotFoundError: No module named 'dash'

(Second update) I am running the same script in Atom. Unfortunately it doesn't seen to be working: enter image description here

I don't understand what I am doing wrong.


Solution

  • This is the tutorial you are looking for https://plot.ly/python/ipython-notebook-tutorial/. As Alexander explained Dash is a web server. If you are just learning python and want to plot stuff with Jupyter, running a webserver is not what you need. Instead you have to install a plot library like plotly or my favorite matplotlib. To install it, you would run ! pip install plotly from inside Jupyter. The tutorial will walk you through it.