Python gmplot没有服装'GoogleMapPlotter' [英] Python gmplot has no attitribute 'GoogleMapPlotter'

查看:188
本文介绍了Python gmplot没有服装'GoogleMapPlotter'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试第一次使用gmplot.我安装好了.我试图运行示例代码只是为了在开始执行任何操作之前先查看其工作原理,并获得以下信息: AttributeError:模块"gmplot"没有属性"GoogleMapPlotter"

I am trying to use gmplot for the first time. I installed it fine. I was trying to run the sample code just to see it work before I started to do anything, and got this: AttributeError: module 'gmplot' has no attribute 'GoogleMapPlotter'

以下是gmplot的示例代码:

Below is the sample code for 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 API客户端库

I installed Google API Client Libraries

pip install --upgrade google-api-python-client

,然后升级gmplot.

and then upgraded gmplot.

pip install --upgrade gmplot

我尝试在Python 2.7和3.6上运行它.

I tried running it with Python 2.7 and 3.6.

所有结果相同.有什么想法吗?

All with the same result. Any ideas?

推荐答案

尝试使用以下方法卸载gmplot:

Try to uninstall gmplot with:

sudo pip uninstall gmplot

然后重新安装它.我使用pip3来安装该软件包,并获得了1.20版本. github自述文件提供的示例脚本无法立即使用,而只是为了说明用法.

Then reinstall it. I used pip3 to install the package and I got the 1.20 version. The sample script provided by the github readme doesn't work out of the box but it is just to illustrate the usage.

尝试一下并将其保存为test.py

Try this and save it 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文件应出现在您的文件夹中.

Execute it with python3 test.py and a mymap.html file should appear in your folder.

这篇关于Python gmplot没有服装'GoogleMapPlotter'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆