2

我是新来的。当我尝试在 chrome 或 Firefox 中连接http://127.0.0.1:8050/时,它显示一个空白网页。

我在 chrome 和 firefox 浏览器中都试过了。我已按照本网站https://dash.plot.ly/installation中提到的安装程序进行操作

pip install dash==1.0.2  # The core dash backend
pip install dash-daq==0.1.0  # DAQ components (newly open-sourced!)

我使用了这段代码。

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

空白网页

终端截图

空白网页

js 控制台 网络控制台 错误消息在 javascript 控制台中

TypeError: dependencies.forEach is not a function
at graphs (dependencyGraph.js:14)
at combination (combineReducers.js:120)
at reducer.js:66
at reducer.js:102
at dispatch (createStore.js:165)
at index.js:11
at UnconnectedContainer.initialization (APIController.react.js:63)
at UnconnectedContainer.componentWillReceiveProps 
(APIController.react.js:33)
at Zf (react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:67)
at qg (react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:95)
Bg @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:117  
c.callback @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:126
Ag @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:116
zg @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:116
qi @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:131
ui @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:133
(anonymous) @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
unstable_runWithPriority @ react@16.8.6.min.js? 
v=1.0.0&m=1564319210:27
Vc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
Sc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
Z @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:156
Kc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:155
ya @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:153
enqueueSetState @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:202
t.setState @ react@16.8.6.min.js?v=1.0.0&m=1564319210:20
handleChange @ connect.js:302
dispatch @ createStore.js:173
(anonymous) @ index.js:11
dispatch @ applyMiddleware.js:35
(anonymous) @ api.js:53
Promise.then (async)
(anonymous) @ api.js:52
Promise.then (async)
(anonymous) @ api.js:46
(anonymous) @ index.js:8
initialization @ APIController.react.js:58
componentDidMount @ APIController.react.js:29
qi @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:130
ui @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:133
(anonymous) @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
unstable_runWithPriority @ react@16.8.6.min.js? 
v=1.0.0&m=1564319210:27
Vc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
Sc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
Z @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:156
Kc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:155
ya @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:153
bh @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:160
xe @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:160
nb.render @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:215
(anonymous) @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:164
$g @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:159
Wc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:164
render @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:217
DashRenderer @ DashRenderer.js:12
(anonymous) @ (index):28
api.js:73 Uncaught (in promise) TypeError: err.text is not a 
 function at api.js:73 (anonymous) @ api.js:73
 Promise.catch (async)
 (anonymous) @ api.js:45
 (anonymous) @ index.js:8
 initialization @ APIController.react.js:58
 componentDidMount @ APIController.react.js:29
 qi @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:130
 ui @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:133
 (anonymous) @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
 unstable_runWithPriority @ react@16.8.6.min.js? 
 v=1.0.0&m=1564319210:27
 Vc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
 Sc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:158
 Z @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:156
 Kc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:155
 ya @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:153
 bh @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:160
 xe @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:160
 nb.render @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:215
 (anonymous) @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:164
 $g @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:159
 Wc @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:164
 render @ react-dom@16.8.6.min.js?v=1.0.0&m=1564319210:217
 DashRenderer @ DashRenderer.js:12
 (anonymous) @ (index):28

操作系统:ubuntu 16.04 LTS 浏览器:google chrome 版本 74.0.3729.169(官方构建)(64 位)版本 74.0.3729.169(官方构建)(64 位)

dash -1.0.2,dash-core-components -1.0.0,dash-html-components -1.0.0,dash-renderer -1.0.0,dash-table -4.0.2

4

2 回答 2

3

您可能已经知道这一点,但我之前已经看到过这个debug=True问题。

我在 Ubuntu 16.04 机器上运行了您的示例,但我更改了:

app.run_server(debug=True)

至:

app.run_server(debug=False)

并且示例运行良好。(我只用 Mozilla 测试过)。

您还可以运行指定端口和主机的 Dash 应用程序:

app.run_server(host='127.0.0.1',port=8700)

希望有帮助。

于 2019-09-26T23:42:38.230 回答
0

我在 Google Chrome 中运行了您的代码,但没有发现有关显示问题的任何问题。请检查屏幕截图。在此处输入图像描述

于 2021-09-06T13:35:22.147 回答