python - 如何修复 "googlemaps.exceptions.ApiError : REQUEST_DENIED"

标签 python google-maps google-maps-api-3 google-geocoding-api

这是我第一次使用谷歌地图API来获取数据。我已经从谷歌云平台请求了一个API key 。但是,仍然弹出这个错误“Googlemaps.exceptions.ApiError: REQUEST_DENIED (This API project is notauthorized to use this API.)”。请帮忙!

# -*- coding: UTF-8 -*-
import io
import sys
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
from googlemaps import Client
from pprint import pprint

API_KEY = 'MY_API_KEY'

gmaps = Client(key=API_KEY)
geocode_result = gmaps.geocode("臺北市")
pprint(geocode_result)
googlemaps.exceptions.ApiError: REQUEST_DENIED (This API project is not authorized to use this API.)

最佳答案

要使用地理编码 API Web 服务,您需要首先在项目中启用它。按照 Google's guide 中的步骤操作。另请确保您的 API key 为 properly restricted .

希望这有帮助。

关于python - 如何修复 "googlemaps.exceptions.ApiError : REQUEST_DENIED",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57406390/

相关文章:

python - 在类中,来自一种方法的变量在一秒钟内使用?

python - 通过 SSH 传输 pickle 字节

google-maps - 将 KMZ 文件添加到我的 Google map 时,有没有办法将图像叠加在多边形之上?

c#-4.0 - 如何计算谷歌地图圆半径js到C#

javascript - 如何以编程方式更改 Google map 的缩放级别?

python - Or-Tools CP-SAT 求解器导出/导入 : how to access vars after loading a model?

python27 matplotlib : first and last element connected

jquery - 地理编码超出查询限制解决方法

java - 我的 GoogleMap 应用程序无法运行,但 logcat 中没有错误

android - 谷歌地图标记拖动事件在 android 中不起作用