【问题标题】:Dash in offline mode without internet . show loding.. only with no graphs shown在没有互联网的情况下以离线模式冲刺。显示正在加载.. 仅没有显示图表
【发布时间】:2019-01-08 19:09:27
【问题描述】:

我在刚刚加载的页面中没有看到任何图表,也没有显示图表 enter image description here

我的python版本是:Anaconda 3 Python 3.6.4 我的服务器:centos7 无法访问互联网

首先我安装了 dash 所有源和 python setup.py 安装所有源

install dash 0.22.0 
install dash-renderer 0.13.0 
install dash-html-components 0.11.0 
install dash-core-components 0.26.0 
install plotly the latest version

我尝试使用 Chrome、Firefox 和 Internet Explorer 等多种浏览器打开页面,但仍然显示加载。

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.offline as offline
import plotly.graph_objs as go


app = dash.Dash()
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
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,host = '0.0.0.0',port=5001)

我重试做资产文件夹并放 custom-script.js header.css 排版.css

put 仍然不显示任何东西,只是加载...

inspect element Network Monitor image png without assets folder 我该如何解决这个问题?

link for the issue in dash form i open

【问题讨论】:

    标签: plotly dashboard plotly-dash


    【解决方案1】:

    默认情况下,plotly dash 使用 CDN 来提供一些文件。

    要离线使用,您必须在代码中指定。

    小例子:

    # -*- coding: utf-8 -*-
    import dash
    import dash_core_components as dcc
    import dash_html_components as html
    
    app = dash.Dash()
    
    # Serve files locally
    app.css.config.serve_locally = True
    app.scripts.config.serve_locally = True
    
    app.layout = html.Div(
        [ html.H1("This is a test")]
    )
    
    if __name__ == '__main__':
        app.run_server(debug=True)
    

    【讨论】:

    • 我已经这样做了,但页面给我加载的问题仍然相同......在我输入 app.css.config.serve_locally = True app.scripts.config.serve_locally = True
    • 请添加一个最小的例子。
    • 是的,你输入的示例代码和加载结果仍然相同。我附上了我测试的代码和我尝试做的所有方法
    • Chrome 中的网络监视器显示什么?它是否尝试加载外部资源或显示一些错误?
    • 这解决了我的问题——在公司网络中运行 dash
    【解决方案2】:

    谢谢你,我已经通过卸载 dash-renderer 0.13.0 解决了它并再次安装它我意识到当我打开监控网络时没有 GET 用于 dash-layout 或 dash-dependencies 所以我尝试卸载 dash-renderer 0.13 .0 并再次安装它,现在它的工作谢谢你

    【讨论】:

      【解决方案3】:

      谢谢你,我已经通过卸载 dash-renderer 0.13.0 解决了它并再次安装它我意识到当我打开监控网络时没有 GET 用于 dash-layout 或 dash-dependencies 所以我尝试卸载 dash-renderer 0.13 .0 并再次安装它并立即工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-25
        • 2022-10-07
        • 1970-01-01
        相关资源
        最近更新 更多