Skip to main content
 首页 » 编程设计

python之属性错误 : Map object has no attribute 'create_map'

2024年09月07日34lonelyxmas

我需要一些帮助,我尝试在我的代码中使用 folium 但不断收到此错误消息:

Attribute Error : Map object has no attribute 'create_map'

这是我得到的(列表中没有 create_map):

dir(folium.Map) 
 
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__',  
 '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',  
 '__init__', '__init_subclass__', '__le__', '__lt__', '__module__',  
 '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',  
 '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__',  
 '_get_self_bounds', '_repr_html_', '_repr_png_', '_to_png', 'add_child' ,  
 'add_children', 'add_tile_layer', 'add_to', 'choropleth', 'fit_bounds',  
'get_bounds', 'get_name', 'get_root', 'render', 'save', 'to_dict', 'to_json'] 

代码是:

import folium 
map_osm = folium.Map(location=[45.5236, -122.6750]) 
map_osm.create_map(path='osm.html') 

附言:folium 版本 0.5.0//Python 3.6.4

请您参考如下方法:

您可以使用save 方法将 map 保存为HTML。

例如

map_osm.save('osm.html') 

在 dir(folium.Map) 的输出中也提到了它