Google python地理定位器:SSL证书\u VERIFY\u失败

2024-06-30 14:52:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试使用google地理定位器时遇到了ssl错误。这很奇怪,因为同一个项目在其他计算机上运行良好。在

代码如下:

from geopy.geocodersimport GoogleV3
geolocator = GoogleV3(my_key)
location = geolocator.geocode("1 rue Martel, 75010 Paris")

问题是:

^{pr2}$

以下是我的配置: 麦考斯, 地质1.11.0, Python 3.6.1

非常感谢你的帮助!在


Tags: 项目key代码fromsslmy计算机错误
1条回答
网友
1楼 · 发布于 2024-06-30 14:52:43

您可以尝试在geolocator=赋值之前添加下面的代码,以暂时禁用SSL证书验证。在

import ssl 

# Disable SSL certificate verification
try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
    # Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context

希望这能有所帮助。在

相关问题 更多 >