Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 具有API密钥的PyGeocoder_Python_Google Maps Api 3 - Fatal编程技术网

Python 具有API密钥的PyGeocoder

Python 具有API密钥的PyGeocoder,python,google-maps-api-3,Python,Google Maps Api 3,我正在使用PyGeocoder 我使用简单服务器选项创建了一个API密钥,但这并没有为我提供客户机ID选项 所以我有代码: from pygeocoder import Geocoder business_geocoder = Geocoder(None, 'MY_API_KEY') address_string = "London, United Kingdom" results = business_geocoder.geocode(address_string) 这很好,但是我的报价使

我正在使用PyGeocoder

我使用简单服务器选项创建了一个API密钥,但这并没有为我提供客户机ID选项

所以我有代码:

from pygeocoder import Geocoder
business_geocoder = Geocoder(None, 'MY_API_KEY')
address_string = "London, United Kingdom"
results = business_geocoder.geocode(address_string)
这很好,但是我的报价使用情况没有在管理控制台窗口中报告,我可以将我的API_键更改为任何值,它仍然有效。是否有其他人使用此功能?如果有,您是如何实现的

例如,该代码有效

business_geocoder = Geocoder(client_id=None, private_key='whatever')
此代码给出了一个错误:

business_geocoder = Geocoder(client_id="some", private_key='whatever')

pygeolib.GeocoderError: Error Forbidden, 403
Query: https://maps.google.com/maps/api/geocode/json?language=&region=&signature=hrlktNatq4RvlN9Cvd6VNQf8FMw%3D&bounds=&client=some&components=&address=Barnfield+Drive%2C+Chichester%2C+United+Kingdom&sensor=false
谷歌似乎表示,地理编码API不支持简单的API密钥认证方法,但它们仍能以某种方式工作

我刚刚更新了的1.2.3版,所以您应该可以这样做

Geocoder('YOUR_API_KEY').geocode(...
升级模块后

pip install --upgrade pygeocoder