我第一次尝试使用gmplot。我安装得很好。在开始执行任何操作之前,我试图运行示例代码以确保它的工作,并得到以下结果: AttributeError:模块“gmplot”没有属性“GoogleMapPlotter”
下面是gmplot的示例代码:
import gmplot
gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)
gmap.plot(latitudes, longitudes, 'cornflowerblue', edge_width=10)
gmap.scatter(more_lats, more_lngs, '#3B0B39', size=40, marker=False)
gmap.scatter(marker_lats, marker_lngs, 'k', marker=True)
gmap.heatmap(heat_lats, heat_lngs)
gmap.draw("mymap.html")我安装了Google客户端库
pip install --upgrade google-api-python-client然后升级gmplot。
pip install --upgrade gmplot我尝试用Python2.7和3.6运行它。
结果都是一样的。有什么想法吗?
发布于 2018-01-25 15:35:06
尝试用以下方式卸载gmplot:
sudo pip uninstall gmplot然后重新安装它。我使用pip3来安装这个包,我得到了1.20版本。github提供的示例脚本没有开箱即用,只是为了说明用法。
试试这个,保存它,test.py
import gmplot
gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)
latitudes = [37.428,]
longitudes = [-122.145,]
more_lats = [37.429,]
more_lngs = [-122.147,]
gmap.plot(latitudes, longitudes, 'cornflowerblue', edge_width=10)
gmap.scatter(more_lats, more_lngs, '#3B0B39', size=40, marker=False)
gmap.draw("mymap.html")使用python3 test.py执行它,mymap.html文件应该出现在您的文件夹中。
https://stackoverflow.com/questions/46833218
复制相似问题