TypeError:__init __()获得了意外的关键字参数'external_stylesheets'

时间:2019-06-27 08:04:32

标签: python plotly-dash

我正在尝试制作我的第一个Dash应用程序,但遇到一个或多个问题。

这是我的完整代码(不要关注法语注释)。那不是开发的代码,我只是想发现Dash:

# -*- coding: utf-8 -*-

### Importation des librairies

import dash
import dash_core_components as dcc # Graphs
import dash_html_components as html # Tags
from dash.dependencies import Input, Output, Event
from pandas_datareader import DataReader
import time
import pandas as pd
import plotly
import plotly.graph_objs as go
from collections import deque
import random
import os
import pandas as pd
import glob
import numpy as np
import statistics
from datetime import *
from pytz import *

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets) # Starting application

app.layout = html.Div(children=[ # HTML of the entire project
    html.H1(children='Générez votre fichier de données !'), # H1 = Titre 1 en HTML, premier "enfant"

    html.Div(children='''
        Dash: A web application framework for Python.
    '''), # Deuxième enfant

    html.Div([
    html.Div(
            dcc.Checklist(
                options=[
                    {'label': 'Inlet 1 ST1', 'value': 'I1ST1'},
                    {'label': 'Inlet 2 ST1', 'value': 'I2ST1'},
                    {'label': 'Inlet 3 ST1', 'value': 'I3ST1'},
                    {'label': 'Inlet 4 ST1', 'value': 'I4ST1'},
                    {'label': 'Inlet 5 ST1', 'value': 'I5ST1'},
                    {'label': 'Inlet 6 ST1', 'value': 'I6ST1'},
                        ],
                labelStyle = {'display': 'block'}
                        )
            ),

    html.Div(
            dcc.Checklist(
                     options=[
                    {'label': 'Inlet 1 ST2', 'value': 'I1ST2'},
                    {'label': 'Inlet 2 ST2', 'value': 'I2ST2'},
                    {'label': 'Inlet 3 ST2', 'value': 'I3ST2'},
                    {'label': 'Inlet 4 ST2', 'value': 'I4ST2'},
                    {'label': 'Inlet 5 ST2', 'value': 'I5ST2'},
                    {'label': 'Inlet 6 ST2', 'value': 'I6ST2'},
                        ],
                labelStyle = {'display': 'block'}
                        )
            ),

    html.Div(
            dcc.Checklist(
                options=[
                    {'label': 'Inlet 1 MT', 'value': 'I1MT'},
                    {'label': 'Inlet 2 MT', 'value': 'I2MT'},
                    {'label': 'Inlet 3 MT', 'value': 'I3MT'}
                        ],
                labelStyle = {'display': 'block'}
                        )
            )]
            )

])

if __name__ == '__main__':
    app.run_server(debug=True) # Running the application

我只是修改代码片段并刷新应用程序,直到无法启动它为止。首先,我可以在Spyder上启动该应用程序,但会在我的浏览器(chrome)上收到该消息:

Error loading layout

1小时后,错误已更改。这次我在Spyder中得到了它:

TypeError: __init__() got an unexpected keyword argument 'external_stylesheets'

因此,我尝试使用“ external_sheetsheets”删除部分代码,然后在浏览器上收到了该消息(带有大量回溯):

builtins.AttributeError
AttributeError: module 'plotly' has no attribute 'config'

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object

我不记得在停止运行之前已经修改了任何代码,但是如果我这样做了,我尝试启动示例Dash应用程序(使用SF和Montréal),但是它做了相同的事情!

然后,我尝试在另一台计算机上启动代码,然后再次出现“错误加载布局”。我还尝试在其上启动Dash示例,效果很好!

因此,我只是尝试再次尝试在第一台计算机上启动代码和示例应用程序。但是对于他们两个我又得到了:

TypeError: __init__() got an unexpected keyword argument 'external_stylesheets'

作为一个贫穷的非英语初学者,我找不到问题所在。我的代码可以在您的计算机上运行吗?问题出在哪里?我该怎么做才能解决所有问题?

谢谢您的帮助!

0 个答案:

没有答案