错误尝试在Spyder IPython控制台中初始化Dash

问题描述 投票:2回答:1

尝试使用Dash运行简单的仪表板时出现错误。我在Python 3.4中使用Spyder。我有pip installed dash, dash_core_components, dash_html_compenents ..

我的代码:

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'),

    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)

这是从Dash/Plotly website tutorial直接采取的

我收到以下错误:

 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
 * Restarting with stat
C:\Users\mwolfe\AppData\Local\Continuum\anaconda3\envs\py34\lib\site-packages\IPython\core\interactiveshell.py:2889: UserWarning:

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

An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

当我去http://127.0.0.1:8050/尝试查看示例仪表板时它将无法加载。

我已经尝试过this来解决这个问题,但是还没有能够解决这个问题。

python spyder plotly-dash
1个回答
0
投票

设置debug=False确实解决了这个问题,但没有使用Jupyter笔记本和Spyder。使用notebook / spyder执行代码时会陷入困境。

将代码更改为debug=False并在Anaconda Navigator附带的PyQt控制台中执行。有用。

© www.soinside.com 2019 - 2024. All rights reserved.