gpt4 book ai didi

Python- Urllib2 : [Errno 54] Connection reset by peer

转载 作者:行者123 更新时间:2023-12-01 09:36:36 25 4
gpt4 key购买 nike

使用 Urllib2 时出现以下错误:

[Errno 54] 连接被对端重置

代码如下:

import urllib2   
url = "https://api.thousandeyes.com/";
response = urllib2.urlopen(url, context=ctx);

这里是错误:

nnayar$ python test2.py
OpenSSL 0.9.8zh 14 Jan 2016
Traceback (most recent call last):
File "test2.py", line 13, in <module>
response = urllib2.urlopen(url);
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open
context=self._context)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 54] Connection reset by peer>

我该如何解决这个问题?

最佳答案

API 最近弃用了导致此问题的 TLS 1.0 支持。我现在正在努力升级 python 以使用 TLS1.2,这也非常具有挑战性,因为 Python 的 Mac 默认安装仅支持 TLS 1.0。

关于Python- Urllib2 : [Errno 54] Connection reset by peer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48573631/

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