Python 加载布局时出现绘图破折号错误

Python 加载布局时出现绘图破折号错误,python,flask,plotly-dash,Python,Flask,Plotly Dash,您好,我是Dash的新手,我正在按照页面上的教程进行操作,我遇到了一个错误,引用msgpack not installed。我后来安装了它,然后运行页面上给出的以下代码 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 D

您好,我是Dash的新手,我正在按照页面上的教程进行操作,我遇到了一个错误,引用msgpack not installed。我后来安装了它,然后运行页面上给出的以下代码

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':[2,4,1],'type':'bar','name':'SF'}
            ],
            'layout': {
                'title':'Dash Data Visualisation'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)
当我继续这样做时,我得到以下错误

Error loading layout

我阅读了dash文档和社区帮助,其中有一些类似的问题,但我无法理解。请帮助。

当我在终端中运行时,
代码运行良好。该链接显示了一个
条形图
(如下)。可能是您的
dash
安装缺少一些
/
要求
文件。您可以尝试从终端执行下面列出的包的
pip安装
conda安装

有关如何使用
pip安装的示例

$ pip install <package name here>
例如:

$ pip install chardet==3.0.4
套餐

chardet==3.0.4
click==6.7
Cython==0.28.2
dash==0.21.0
dash-core-components==0.22.1
dash-html-components==0.10.0
dash-renderer==0.12.1
decorator==4.3.0
nbformat==4.4.0
numpy==1.14.2
pandas==0.22.0
pandas-datareader==0.6.0
plotly==2.5.1
python-dateutil==2.7.2
pytz==2018.4
requests==2.18.4
urllib3==1.22
Werkzeug==0.14.1

编辑-1

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')])
if __name__ == '__main__':
    app.run_server(debug=True)
根据输入,添加下面要导入的行

import dash
import dash_core_components as dcc
import dash_html_components as html
from dashapp import app as application

app = dash.Dash()
app.layout = html.Div(children=[html.H1(children='Hello Dash')])
if __name__ == '__main__':
    app.run_server(debug=True)

和/或更改以下任一项:

编辑-2

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')])
if __name__ == '__main__':
    app.run_server(debug=True)


我再次删除了所有库并重新安装了它们,还用Chrome运行了代码。它现在运转良好

我也是Dash新手,在我的例子中,语法有问题

我是这样做的:

app.layout = html.Div({
正在获取“错误加载布局”

但当我换成这个的时候:

app.layout = html.Div(children=[
错误消失了


检查主Div的语法是否有错误。

Hi Nilesh,我已经安装了dash网站上提到的所有依赖项和库。我重新安装了它们并再次运行该命令,但错误相同:(如果您在
code
的第4行尝试
app=dash.dash(\uuuu name\uuuuuuuuuu)
该怎么办。仍然相同:(在看了一些
帖子之后,我从
Edit-1
中添加了一些可能有效的建议。如果不起作用,那么另一个选项是
卸载
,然后
重新安装
。嗨,Nikhil,我按照你说的做了。现在,我收到一个错误,说没有安装名为dashapp的模块,当我ied使用pip安装dashapp,我收到消息说没有名为dashappHi Sahil的模块,欢迎使用StackOverflow!您能格式化您的代码吗?您可以阅读这里和这里,谢谢!
app = Dash()
app = dash.Dash(__name__)
server = app.server
pip install dash==0.21.1  # The core dash backend
pip install dash-renderer==0.13.0  # The dash front-end
pip install dash-html-components==0.11.0  # HTML components
pip install dash-core-components==0.24.0  # Supercharged components
pip install plotly --upgrade  # Latest Plotly graphing library
pip install dash.ly --upgrade
app.layout = html.Div({
app.layout = html.Div(children=[