简书链接:pythonssl错误proxy错误解决思路
文章字数:92,阅读全文大约需要1分钟
requests.exceptions.SSLError: HTTPSConnectionPool(host=’explorer.api.openai.com’, port=443): Max retries exceeded with url: /api/auth/csrf (Caused by SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:997)’)))

pip install --upgrade requests

1
2
3
4
5
6
7
8
9
10
   requests.packages.urllib3.disable_warnings()
requests.adapters.DEFAULT_RETRIES = 30 # 增加重连次数
response = self.session.get(
url=url,
headers=headers,
timeout=(55, 55),
verify=False
)
self.session = requests.Session()
self.session.keep_alive = False # 关闭多余连接
1
2
3
4
5
6
7
import requests

# 禁用 SSL 验证
requests.packages.urllib3.disable_warnings()

response = requests.get("https://explorer.api.openai.com", verify=False)
print(response.text)

Cannot connect to proxy.’问题

1
2
3
4
5
6
7
8
9
10
11
12
import requests

proxies = {
"http": "http://yourproxyaddress:port",
"https": "http://yourproxyaddress:port",
}

try:
response = requests.get("https://www.example.com", proxies=proxies)
print(response.text)
except requests.exceptions.ProxyError as e:
print(e)

(Caused by ProxyError(‘Cannot connect to proxy.’, FileNotFoundError(2, ‘No such file or directory’))
降级版本
pip install urllib3==1.25.11

h