"加载依赖项时出错"在企业IE和Chrome

时间:2018-04-24 00:30:14

标签: python python-3.x plotly plotly-dash

我在公司安装的Internet Explorer 11和Chrome 51中收到错误消息“加载依赖项”,但在我自己安装的最新Chrome中没有。此外,如果我打开开发人员工具,Internet Explorer工作正常。

IE控制台提供以下错误消息

HTML1300: Navigation occurred.
supplier
This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.

SCRIPT5009: 'Uint8ClampedArray' is undefined
plotly-1.35.2.min.js (7,1186569)

SCRIPT5009: 'Set' is undefined
bundle.js (21,23784)

Error: dash_core_components was not found.
   {
      [functions]: ,
      description: "dash_core_components was not found.",
      message: "dash_core_components was not found.",
      name: "Error",
      stack: "Error: dash_core_components was not found.
   at e.default.resolve (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:9:28196)
   at s (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:9:16176)
   at s (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:9:15719)
   at value (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:9:16980)
   at b._renderValidatedComponentWithoutOwnerOrContext (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/react-dom@15.4.2.min.js?v=0.11.3:13:10739)
   at b._renderValidatedComponent (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/react-dom@15.4.2.min.js?v=0.11.3:13:10870)
   at b.performInitialMount (http://<url>:"
   }

Unhandled promise rejection TypeError: Unable to get property 'find' of undefined or null reference
   "Unhandled promise rejection"
   {
      [functions]: ,
      description: "Unable to get property 'find' of undefined or null reference",
      message: "Unable to get property 'find' of undefined or null reference",
      name: "TypeError",
      number: -2146823281,
      stack: "TypeError: Unable to get property 'find' of undefined or null reference
   at l (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:1:29665)
   at Anonymous function (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:1:29458)
   at Anonymous function (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:29:941)
   at f.dispatch (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:29:1326)
   at Anonymous function (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:1:30985)
   at u (http://<url>:8080/supplier/_dash-component-suites/dash_renderer/bundle.js?v=0.11.3:15:22048)
   at Anonymous function (http://<url>:8080/supplier/_dash-component-suites/"
   }

这是我的破折号应用程序的大量精简版,会产生同样的错误。 tool是我的包中有一个烧瓶实例。

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd
from functools import partial
import datetime as dt

from tool import server, session, blu, cache, CACHE_TIMEOUT

app_tst = dash.Dash(__name__, server=server, url_base_pathname='/ie_test/')
app_tst.css.config.serve_locally = True
app_tst.scripts.config.serve_locally = True

app_tst.layout = html.Div([
    "hi!",
    dcc.Dropdown(
        id='tstdropdown',
        options=[{'label': str(x+1), 'value': str(x)} for x in range(10)],
        placeholder='Dropdown test'
    ),
    dcc.RadioItems(
        options=[
            {'label': '1', 'value': '1'},
            {'label': '2', 'value': '2'},
            {'label': '3', 'value': '3'},
        ],
        value='3',
        id='radiotest'
    ),
    dcc.RangeSlider(
        id='rangetest',
        min=0,
        max=10,
        marks=[str(x) for x in range(11)],
        pushable=0,
        value=5
    ),
    dcc.Graph(
        id='graphtest',
        figure={}
    )
])

当我删除dcc.Graphdcc.RangeSlider时,该应用运行正常。单独使用dcc.Graphdcc.RangeSlider也会产生"error loading dependencies"问题。

我尝试过以下方法:

  • 'IE=edge'添加到我在烧瓶中的标题
  • 使用app_vndr.css.config.serve_locally = Trueapp_vndr.scripts.config.serve_locally = True在本地提供脚本,并使用烧录函数将/static/path:path/路由到正确的文件。
  • 加载babel.js的polyfill。看起来像Plotly已经这样做了,因为我收到了you can only have one instance of babel.js消息。

我应该注意什么来解决这个问题?我觉得我错过了一些愚蠢的东西,但我不知道该怎么检查或尝试。

1 个答案:

答案 0 :(得分:0)

在情节论坛上与mod讨论后,以下步骤解决了问题:

  • dash-core-components==0.21.0升级到dash-core-components==0.22.1
  • 提供有关图的实际信息

如果没有figure={...}的填充字典,问题仍然存在。

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd
from functools import partial
import datetime as dt

from SupplyChainReportingTool import server, session, blu, cache, CACHE_TIMEOUT
app_tst = dash.Dash(__name__, server=server, url_base_pathname='/ie_test/')
app_tst.css.config.serve_locally = True
app_tst.scripts.config.serve_locally = True

layout = go.Layout(
    yaxis=dict(title='Count',range=[0, 100],fixedrange=True,side='right',zeroline=False,showgrid=False),
    yaxis2=dict(title='percent',range=[0, 1],fixedrange=True,side='left',overlaying='y')
)
data = [go.Scatter(x=[],y=[],name='Data',mode='lines+markers')]

app_tst.layout = html.Div([
    dcc.Graph(
        id='graphtest',
        figure={'data': data, 'layout': layout}
    )
])

通过这项工作,我仍然需要回到dash-core-components==0.21.0,看看这是否真的是一个问题。