Dash refuses to work

My code

import dash
from dash.dependencies import Input, Output
import dash_html_components as html

app = dash.Dash()

app.layout = html.Div([
    **strong text**html.Button(id='submit-button', n_clicks=0, children='Submit'),
    html.Div(id='output-state')
])

@app.callback(Output('output-state', 'children'), [Input('submit-button', 'n_clicks')],)
def print_yes():
    print('yes!')

app.run_server(debug=True)

All i see in the browser is

Loading...

Chrome console

bundle.js Failed to load resource: the server responded with a status of 404 ()
127.0.0.1/:1 Refused to execute script from 'https://unpkg.com/dash-renderer@0.12.1/dash_renderer/bundle.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

Firefox console
Loading failed for the <script> with source “https://unpkg.com/dash-renderer@0.12.1/dash_renderer/bundle.js”.

On python 3.6

$ pipenv graph
boto3==1.6.20
  - botocore [required: <1.10.0,>=1.9.20, installed: 1.9.20]
    - docutils [required: >=0.10, installed: 0.14]
    - jmespath [required: <1.0.0,>=0.7.1, installed: 0.9.3]
    - python-dateutil [required: <2.7.0,>=2.1, installed: 2.6.1]
      - six [required: >=1.5, installed: 1.11.0]
  - jmespath [required: <1.0.0,>=0.7.1, installed: 0.9.3]
  - s3transfer [required: >=0.1.10,<0.2.0, installed: 0.1.13]
    - botocore [required: <2.0.0,>=1.3.0, installed: 1.9.20]
      - docutils [required: >=0.10, installed: 0.14]
      - jmespath [required: <1.0.0,>=0.7.1, installed: 0.9.3]
      - python-dateutil [required: <2.7.0,>=2.1, installed: 2.6.1]
        - six [required: >=1.5, installed: 1.11.0]
dash-core-components==0.21.1
  - dash [required: Any, installed: 0.21.0]
    - Flask [required: >=0.12, installed: 0.12.2]
      - click [required: >=2.0, installed: 6.7]
      - itsdangerous [required: >=0.21, installed: 0.24]
      - Jinja2 [required: >=2.4, installed: 2.10]
        - MarkupSafe [required: >=0.23, installed: 1.0]
      - Werkzeug [required: >=0.7, installed: 0.14.1]
    - flask-compress [required: Any, installed: 1.4.0]
      - Flask [required: Any, installed: 0.12.2]
        - click [required: >=2.0, installed: 6.7]
        - itsdangerous [required: >=0.21, installed: 0.24]
        - Jinja2 [required: >=2.4, installed: 2.10]
          - MarkupSafe [required: >=0.23, installed: 1.0]
        - Werkzeug [required: >=0.7, installed: 0.14.1]
    - plotly [required: Any, installed: 2.5.1]
      - decorator [required: >=4.0.6, installed: 4.2.1]
      - nbformat [required: >=4.2, installed: 4.4.0]
        - ipython-genutils [required: Any, installed: 0.2.0]
        - jsonschema [required: !=2.5.0,>=2.4, installed: 2.6.0]
        - jupyter-core [required: Any, installed: 4.4.0]
          - traitlets [required: Any, installed: 4.3.2]
            - decorator [required: Any, installed: 4.2.1]
            - ipython-genutils [required: Any, installed: 0.2.0]
            - six [required: Any, installed: 1.11.0]
        - traitlets [required: >=4.1, installed: 4.3.2]
          - decorator [required: Any, installed: 4.2.1]
          - ipython-genutils [required: Any, installed: 0.2.0]
          - six [required: Any, installed: 1.11.0]
      - pytz [required: Any, installed: 2018.3]
      - requests [required: Any, installed: 2.18.4]
        - certifi [required: >=2017.4.17, installed: 2018.1.18]
        - chardet [required: <3.1.0,>=3.0.2, installed: 3.0.4]
        - idna [required: <2.7,>=2.5, installed: 2.6]
        - urllib3 [required: <1.23,>=1.21.1, installed: 1.22]
      - six [required: Any, installed: 1.11.0]
dash-html-components==0.9.0
  - dash [required: Any, installed: 0.21.0]
    - Flask [required: >=0.12, installed: 0.12.2]
      - click [required: >=2.0, installed: 6.7]
      - itsdangerous [required: >=0.21, installed: 0.24]
      - Jinja2 [required: >=2.4, installed: 2.10]
        - MarkupSafe [required: >=0.23, installed: 1.0]
      - Werkzeug [required: >=0.7, installed: 0.14.1]
    - flask-compress [required: Any, installed: 1.4.0]
      - Flask [required: Any, installed: 0.12.2]
        - click [required: >=2.0, installed: 6.7]
        - itsdangerous [required: >=0.21, installed: 0.24]
        - Jinja2 [required: >=2.4, installed: 2.10]
          - MarkupSafe [required: >=0.23, installed: 1.0]
        - Werkzeug [required: >=0.7, installed: 0.14.1]
    - plotly [required: Any, installed: 2.5.1]
      - decorator [required: >=4.0.6, installed: 4.2.1]
      - nbformat [required: >=4.2, installed: 4.4.0]
        - ipython-genutils [required: Any, installed: 0.2.0]
        - jsonschema [required: !=2.5.0,>=2.4, installed: 2.6.0]
        - jupyter-core [required: Any, installed: 4.4.0]
          - traitlets [required: Any, installed: 4.3.2]
            - decorator [required: Any, installed: 4.2.1]
            - ipython-genutils [required: Any, installed: 0.2.0]
            - six [required: Any, installed: 1.11.0]
        - traitlets [required: >=4.1, installed: 4.3.2]
          - decorator [required: Any, installed: 4.2.1]
          - ipython-genutils [required: Any, installed: 0.2.0]
          - six [required: Any, installed: 1.11.0]
      - pytz [required: Any, installed: 2018.3]
      - requests [required: Any, installed: 2.18.4]
        - certifi [required: >=2017.4.17, installed: 2018.1.18]
        - chardet [required: <3.1.0,>=3.0.2, installed: 3.0.4]
        - idna [required: <2.7,>=2.5, installed: 2.6]
        - urllib3 [required: <1.23,>=1.21.1, installed: 1.22]
      - six [required: Any, installed: 1.11.0]
dash-renderer==0.12.1
delegator.py==0.1.0
  - pexpect [required: >=4.1.0, installed: 4.4.0]
    - ptyprocess [required: >=0.5, installed: 0.5.2]
gpiozero==1.4.1
ipython==6.2.1
  - decorator [required: Any, installed: 4.2.1]
  - jedi [required: >=0.10, installed: 0.11.1]
    - parso [required: ==0.1.1, installed: 0.1.1]
  - pexpect [required: Any, installed: 4.4.0]
    - ptyprocess [required: >=0.5, installed: 0.5.2]
  - pickleshare [required: Any, installed: 0.7.4]
  - prompt-toolkit [required: <2.0.0,>=1.0.4, installed: 1.0.15]
    - six [required: >=1.9.0, installed: 1.11.0]
    - wcwidth [required: Any, installed: 0.1.7]
  - pygments [required: Any, installed: 2.2.0]
  - setuptools [required: >=18.5, installed: 39.0.1]
  - simplegeneric [required: >0.8, installed: 0.8.1]
  - traitlets [required: >=4.2, installed: 4.3.2]
    - decorator [required: Any, installed: 4.2.1]
    - ipython-genutils [required: Any, installed: 0.2.0]
    - six [required: Any, installed: 1.11.0]
maya==0.3.4
  - dateparser [required: Any, installed: 0.7.0]
    - python-dateutil [required: Any, installed: 2.6.1]
      - six [required: >=1.5, installed: 1.11.0]
    - pytz [required: Any, installed: 2018.3]
    - regex [required: Any, installed: 2018.2.21]
    - tzlocal [required: Any, installed: 1.5.1]
      - pytz [required: Any, installed: 2018.3]
  - humanize [required: Any, installed: 0.5.1]
  - pendulum [required: Any, installed: 1.4.4]
    - python-dateutil [required: <3.0.0.0,>=2.6.0.0, installed: 2.6.1]
      - six [required: >=1.5, installed: 1.11.0]
    - pytzdata [required: >=2018.3.0.0, installed: 2018.3]
    - tzlocal [required: <2.0.0.0,>=1.5.0.0, installed: 1.5.1]
      - pytz [required: Any, installed: 2018.3]
  - pytz [required: Any, installed: 2018.3]
  - ruamel.yaml [required: Any, installed: 0.15.37]
  - tzlocal [required: Any, installed: 1.5.1]
    - pytz [required: Any, installed: 2018.3]
python-vlc==3.0.102
Telethon==0.18.2.2
  - pyaes [required: Any, installed: 1.6.1]
  - rsa [required: Any, installed: 3.4.2]
    - pyasn1 [required: >=0.1.3, installed: 0.4.2]
zproc==0.14
  - zmq [required: Any, installed: 0.0.0]
    - pyzmq [required: Any, installed: 17.0.0]

maybe this ?

**strong text**

would try without first

and then add a parameter in your print_yes() callback function

this works :

import dash
from dash.dependencies import Input, Output
import dash_html_components as html

app = dash.Dash()

app.layout = html.Div([
    html.Button(id='submit-button', n_clicks=0, children='Submit'),
    html.Div(id='output-state')
])
@app.callback(Output('output-state', 'children'), [Input('submit-button', 'n_clicks')],)
def print_yes(arg):
    print('yes!')

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

Oh dang, looks like a problem with the unpkg.com hosted 0.12.3 version of the dash-renderer library. Two workarounds until this gets fixed:

  1. Roll back the latest dash-renderer to the last working version

    $ pip install dash-renderer==0.11.3

  2. Switch to using the local Dash scripts

    app.scripts.config.serve_locally = True

Paging @chriddyp

Thanks for reporting! For some reason, the NPM package didn’t upload correctly. That’s been fixed, so the existing dash-renderer==0.12.1 should work now :+1:

1 Like