gpt4 book ai didi

python - MacOS 高 OSierra 10.13.6,Python3.7,GeocoderServiceError : [SSL: CERTIFICATE_VERIFY_FAILED]

转载 作者:太空宇宙 更新时间:2023-11-03 14:31:48 25 4
gpt4 key购买 nike

我最近在 macOS High OSierra 上安装了 python 3.7,并花了很长时间试图让它工作。那个问题是here .目前我在使用以下代码时遇到问题,想知道是否有人可以提供帮助。

import geopy
geocoder = geopy.geocoders.GoogleV3(domain = "maps.google.co.uk")
geocoder.geocode("Cambridge", exactly_one = False)

导致以下错误:

SSLCertVerificationError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1316
h.request(req.get_method(), req.selector, req.data, headers, -> 1317 encode_chunked=req.has_header('Transfer-encoding')) 1318
except OSError as err: # timeout error

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked) 1228
"""Send a complete request to the server.""" -> 1229 self._send_request(method, url, body, headers, encode_chunked) 1230

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1274 body = _encode(body, 'body') -> 1275 self.endheaders(body, encode_chunked=encode_chunked) 1276

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked) 1223
raise CannotSendHeader() -> 1224 self._send_output(message_body, encode_chunked=encode_chunked) 1225

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked) 1015
del self._buffer[:] -> 1016 self.send(msg) 1017

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in send(self, data) 955 if self.auto_open: --> 956 self.connect() 957 else:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in connect(self) 1391 self.sock = self._context.wrap_socket(self.sock, -> 1392 server_hostname=server_hostname) 1393

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py 在 wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs、server_hostname、 session ) 第411章 --> 412 session = session 第413章

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py 在 _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs、server_hostname、上下文、 session ) 攀上漂亮女局长之后849 非阻塞套接字”) --> 850 self.do_handshake() 方法 851 除了 (OSError, ValueError):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py 在 do_handshake(self, block) 1107
self.settimeout(无) -> 1108 self._sslobj.do_handshake() 1109 最后:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1045)

在处理上述异常的过程中,又发生了一个异常:

URLError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, timeout, raw, requester, deserializer, **kwargs) 314 try: --> 315 page = requester(req, timeout=timeout, **kwargs) 316 except Exception as error:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout) 524 --> 525 response = self._open(req, data) 526

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py in _open(self, req, data) 542 result = self._call_chain(self.handle_open, protocol, protocol + --> 543 '_open', req) 544 if result:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args) 502 func = getattr(handler, meth_name) --> 503 result = func(*args) 504 if result is not None:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py in https_open(self, req) 1359 return self.do_open(http.client.HTTPSConnection, req, -> 1360 context=self._context, check_hostname=self._check_hostname) 1361

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1318
except OSError as err: # timeout error -> 1319 raise URLError(err) 1320 r = h.getresponse()

网址错误:

在处理上述异常的过程中,又发生了一个异常:

GeocoderServiceError Traceback(最近调用最后) 在 () ----> 1 geocoder.geocode("剑桥", exactly_one = False)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/geopy/geocoders/googlev3.py 在地理编码中( self ,查询,exactly_one,超时,边界,区域, 组件、语言、传感器) 240 logger.debug("%s.geocode: %s", self.class.name, url) 第241回 --> 242 self._call_geocoder(url, timeout=timeout), exactly_one 243) 第244章

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/geopy/geocoders/base.py 在 _call_geocoder(self, url, timeout, raw, requester, deserializer, **kwargs) 340 如果消息中“超时”: 341 raise GeocoderTimedOut('服务超时') --> 342 引发 GeocoderServiceError(消息) 343 344 if hasattr(页面,'getcode'):

GeocoderServiceError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:证书链中的自签名证书 (_ssl.c:1045)

最佳答案

查看以下链接:here

我能够通过在该页面上运行第二个命令来让它工作:

打开/Applications/Python\3.7/Install\Certificates.command

关于python - MacOS 高 OSierra 10.13.6,Python3.7,GeocoderServiceError : [SSL: CERTIFICATE_VERIFY_FAILED],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52174880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com