python - 使用 simple_plotly 时如何解决“NameError: name 'plotly_version' is not defined”?
问题描述
我正在尝试为我的硕士论文代码绘制地图。到目前为止,我只是在尝试https://nbviewer.jupyter.org/github/e2nIEE/pandapower/blob/develop/tutorials/plotly_maps.ipynb中的一个示例,所以我想一切都应该正常工作。但是,当尝试使用函数“simple_plotly”时,会出现 NameError。我怎样才能让它发挥作用?
这是我得到错误的行:
from pandapower.plotting.plotly import simple_plotly
from pandapower.networks import mv_oberrhein
net = mv_oberrhein()
simple_plotly(net, on_map=True, projection='epsg:31467')
错误
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-8-9381f16ca1ad> in <module>()
9
10 net = mv_oberrhein()
---> 11 simple_plotly(net, on_map=True, projection='epsg:31467')
~/miniconda3/lib/python3.6/site-packages/pandapower/plotting/plotly/simple_plotly.py in simple_plotly(net, respect_switches, use_line_geodata, on_map, projection, map_style, figsize, aspectratio, line_width, bus_size, ext_grid_size, bus_color, line_color, trafo_color, ext_grid_color)
116 **ext_grid_color** (String, 'yellow') - External Grid Color. Init is yellow
117 """
--> 118 version_check()
119 # create geocoord if none are available
120 if 'line_geodata' not in net:
~/miniconda3/lib/python3.6/site-packages/pandapower/plotting/plotly/traces.py in version_check()
33
34 def version_check():
---> 35 if version.parse(plotly_version) < version.parse("3.1.1"):
36 raise UserWarning("Your plotly version {} is no longer supported.\r\n"
37 "Please upgrade your python-plotly installation, "
NameError: name 'plotly_version' is not defined
解决方案
出现此错误是因为未安装 plotly,使用 pip 安装 ploty 即可。
Pip install plotly
推荐阅读
- python - Clean up unlabeled pixels in image segmentation
- mysql - mysql - Applying an outer join to a complex statement
- angular - Angular:如何管理 *ngFor 中的单个复选框
- javascript - 如何使用 AngularJS 根据下拉选择值禁用输入文本框?
- mysql - 如何为 MySQL 查询中的所有记录生成唯一的 UUID?
- php - laravel Can't write image data to path
- matlab - reading the data of a file into matlab, editing it, and saving it elsewhere
- html - 根据从另一个字段中选择动态填充字段
- java - 从用户输入获取双倍值时出错
- android - 在 Android 应用程序中访问声音资产时如何区分文件和内容 URI