Problem running Dash in Google Colab notebook

I’m new to Plotly and am trying to use Dash. I found some sample code in an online tutorial and have tried to run it in a Google Colab notebook, but I get an error from the last two lines of the following code (problematic lines are bolded):

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()

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

    Dash: A web application framework for Python.

        '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’:

When I searched stack overflow to troubleshoot the error (“UnsupportedOperation: not writable”), I found a solution from another user on GitHub, and it was described as:

You need to edit the echo function definition at …/site-packages/click/ the default value for the file parameter must be sys.stdout instead of None.
Do the same for the secho function definition at …/site-packages/click/

Unfortunately, there was no sample code given for how to make the edits indicated to echo and secho, and this is unfamiliar to me.

If you have any other suggestions for how to get Dash to run in a Google Colab notebook, I would love to hear them!

maybe try ‘debug=False’?

Thank you for replying and trying to solve the problem! I tried debug=False and still get the same error message (UnsupportedOperation: not writable).

This might have to do with the new version of flask (1.0+). It started coming up when I upgraded. If you use flask 0.12 for example it should be fine.

If you are using flask 1.0 then this can be solved by saving the script to a file, and running it from the command line.

In Google Colab:

import dash
import ... 

Then from the next cell run:


This worked for me:

One problem: I don’t know how to access the url it is running on, because this is not local on my machine!

Make sure you also correctly write the last two lines:

if __name__ == '__main__':

Thank you, @eliasdabbas!! This did get the ugly error messages to go away (it ran). I haven’t figured out how to get the graph to appear, though. I’ll see if I can find something about how to get that to work, too. Thanks again for your help!

1 Like

Did you manage to run this code? i have the same problem