openai-python: APIConnectionError: Error communicating with OpenAI
Running into certificate errors when trying to ping the API. Happens both in virtualenv
and regular
Python
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/openai/api_requestor.py", line 255, in request_raw
result = _thread_context.session.request(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/engines (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1131)')))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "search.py", line 21, in <module>
main()
File "search.py", line 9, in main
engines = openai.Engine.list()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/openai/api_resources/abstract/listable_api_resource.py", line 27, in list
response, _, api_key = requestor.request(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/openai/api_requestor.py", line 98, in request
result = self.request_raw(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/openai/api_requestor.py", line 265, in request_raw
raise error.APIConnectionError("Error communicating with OpenAI") from e
openai.error.APIConnectionError: Error communicating with OpenAI
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20
都是中国人拽啥洋文XD
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年3月3日(星期五) 晚上6:27 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [openai/openai-python] APIConnectionError: Error communicating with OpenAI (Issue #56)
All methods above can not solve my problem , because I’m in China , where one can’t connect to openai without VPN or Proxy. For my Chinese compatriots following method works: https://www.zhihu.com/question/587322263/answer/2919916984
I’m in China as well. One of my accounts is using a google account by implementing an Indian virtual phone number, and it works only when I don’t use any proxies(As for website login, I need to use VPN to login google account and then close it to use the chatGPT interface). One of my friends’ accounts is signed up with his qqmail and Indian phone number, which can only access openAI by using VPN. That’s weird.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
All methods above can not solve my problem , because I’m in China , where one can’t connect to openai without VPN or Proxy. For my Chinese compatriots following method works: https://www.zhihu.com/question/587322263/answer/2919916984
I figured it out, my VPN was blocking external requests, for anyone who has a M1 Macbook in the future make sure your network calls aren’t being tunneled by another app 😃
Same as win10. I figured out that just now by simply shutting down my clash terminal XD
关闭vpn就链接超时呀