Cannot run even a simple application after upgrading to Dash 1.0.0

Greetings, ever since I upgraded to Dash 1.0.0, I haven’t been able to get a single application working without an inexplicable SYstemExit occurring. For example, if I tried running a script using the code given in Part Two of the Dash tutorial, I would still have that issue. I’ve reproduced the code here:


# -*- 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)


After a short bit, I see the following lines.


runfile('C:/Users/gzucaro/Documents/PythonScripts/Dash/app.py', wdir='C:/Users/gzucaro/Documents/PythonScripts/Dash')
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Debugger PIN: 683-300-392
Debugger PIN: 683-300-392
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3304: UserWarning:

To exit: use 'exit', 'quit', or Ctrl-D.

The full traceback looks like this.


Traceback (most recent call last):

  File "", line 1, in 
    runfile('C:/Users/gzucaro/Documents/PythonScripts/Dash/app.py', wdir='C:/Users/gzucaro/Documents/PythonScripts/Dash')

  File "C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/gzucaro/Documents/PythonScripts/Dash/app.py", line 32, in 
    app.run_server(debug=True)

  File "C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\dash\dash.py", line 1694, in run_server
    self.server.run(port=port, debug=debug, **flask_run_options)

  File "C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\flask\app.py", line 944, in run
    run_simple(host, port, self, **options)

  File "C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\werkzeug\serving.py", line 1007, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)

  File "C:\Users\gzucaro\AppData\Local\Continuum\anaconda3\lib\site-packages\werkzeug\_reloader.py", line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())

SystemExit: 1

Any advice?

Hm… could you try ‘app.run_server(debug=False)’?

Thank you for getting back to me! I figured out the problem, however. This only happened to me when I ran scripts in Spyder’s IPython console. When I ran scripts from command prompt, everything worked again. This is with the latest version of Spyder (v3.3.5).

Re-activating this post because I’m having the same issue. I can’t modify the code in the layout tutorial page without Dash going into system error: 1 or package error. I tried putting everything in a jupyter notebook ipynb file, putting the code in a .py file and running it in an ipynb file notebook, using jupyterlabs (found out the lab-dash extension is not yet available in windows) and using the command prompt. Nothing has worked so far. I eager to start building on Dash so hopefully your team can point me in the right direction. I’m attaching some of of the code and error messages I got. Thank you!


Another error:

AttributeError                            Traceback (most recent call last)
~\Documents\Sebastian\Thinkful\app in <module>
     45
     46 if _name_ == '_main_':
---> 47     app.run_server(debug=True)
~\Anaconda3\lib\site-packages\dash\dash.py in run_server(self, port, debug, dev_tools_ui, dev_tools_props_check, dev_tools_serve_dev_bundles, dev_tools_hot_reload, dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval, dev_tools_hot_reload_max_retry, dev_tools_silence_routes_logging, dev_tools_prune_errors, **flask_run_options)
   1924             self.logger.info("Debugger PIN: %s", debugger_pin)
   1925
-> 1926         self.server.run(port=port, debug=debug, **flask_run_options)
~\Anaconda3\lib\site-packages\flask\app.py in run(self, host, port, debug, load_dotenv, **options)
    988
    989         try:
--> 990             run_simple(host, port, self, **options)
    991         finally:
    992             # reset the first request information if the development server
~\Anaconda3\lib\site-packages\werkzeug\serving.py in run_simple(hostname, port, application, use_reloader, use_debugger, use_evalex, extra_files, reloader_interval, reloader_type, threaded, processes, request_handler, static_files, passthrough_errors, ssl_context)
   1005         from ._reloader import run_with_reloader
   1006
-> 1007         run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
   1008     else:
   1009         inner()
~\Anaconda3\lib\site-packages\werkzeug\_reloader.py in run_with_reloader(main_func, extra_files, interval, reloader_type)
    330             reloader.run()
    331         else:
--> 332             sys.exit(reloader.restart_with_reloader())
    333     except KeyboardInterrupt:
    334         pass
~\Anaconda3\lib\site-packages\werkzeug\_reloader.py in restart_with_reloader(self)
    157         while 1:
    158             _log("info", " * Restarting with %s" % self.name)
--> 159             args = _get_args_for_reloading()
    160
    161             # a weird bug on windows. sometimes unicode strings end up in the
~\Anaconda3\lib\site-packages\werkzeug\_reloader.py in _get_args_for_reloading()
     74     _main_ = sys.modules["_main_"]
     75
---> 76     if _main_._package_ is None:
     77         # Executed a file, like "python app.py".
     78         if os.name == "nt":
AttributeError: module '_main_' has no attribute '_package_'

try ‘app.run_server(debug=False)’, the built in reloader doesn’t work when you run this in jupyter kernels.

1 Like