python - Plotly/dash - 模块“dash_html_components”没有“Div”成员
问题描述
我想从 plotly 运行这段代码。
之前,我安装了这些模块:
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.23.0 # Supercharged components
pip install plotly --upgrade # Latest Plotly graphing library
我的代码是:
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': [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)
但是它不起作用,我不明白为什么!你能帮我吗 !谢谢
解决方案
我知道这是一个老问题,但我最近遇到了这个错误,之前的答案没有帮助。
经过进一步探索,此错误的原因是软件包dash_html_components
已被弃用。
解决方案: 替换 import dash_core_components as dcc
为 from dash import dcc
此外,现在已弃用的其他类似软件包是dash_html_components
推荐阅读
- c# - 在 MVC 下实现的 Blazor 组件未呈现
- php - Stripe Checkout:有没有办法在用户被重定向到的“成功”页面中获取姓名和电子邮件?
- r - 在for循环中将结果附加到向量中会不断覆盖第二项(R)
- python - 即使手动将数据文件复制到位后,“找不到资源 punkt”
- php - 如何在laravel中仅显示日期时间中的日期
- java - Spring boot - 带有返回 id 的 Jdbc 批量插入
- asp.net-core - 对于带有 API 控制器的 .NET Standard 库,我需要哪个 NuGet 包
- sql - SQL 查询 - 计算上一年的销售额
- ruby - 不能使用包含?在方法中使用实例变量
- azure - 用于安全字符串数组的 ARM 模板