Openai cannot import name 'DEFAULT_CIPHERS' problem (Breaking changes with the latest version of requests)

If you built the openai recently in python, you will receive the following error

{"errorMessage": "Unable to import module 'prompt_runner': cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_' (/var/task/urllib3/util/", "errorType": "Runtime.ImportModuleError", "requestId": "5700983c-a460-4e87-bef6-6cbb309d1659", "stackTrace": []}

Because, Openai uses latest version of requests. And requests with the latest version (2.30) started supporting urllib3.2.0 which breaks the import (on AWS)

openAI should consider pinning the urllib3<2 for wider support. I’ll post when I figure a fix for this.

1 Like

Turned out the solution ie easy… you can pin the version in requirements.txt



I have deployed my code in AWS Lambda. I am getting the same error when I am running the code. Where do you suggest I can add requirements.txt?

I got the same problem on AWS too. It depends how you deploy your app to AWS. If you are using terraform or serverless even AWS Toolkit in PyCharm, you can add requirements.txt in same folder where your script is and deployer will handle the rest.

1 Like

Hi this is Arunkarthik Periyaswamy. I have also faced this while creating aws lambda layer pip

. “Unable to import module ‘lambda_function’: cannot import name ‘DEFAULT_CIPHERS’ from ‘urllib3.util.ssl_’ (/opt/python/urllib3/util/”

This is because openai urllib3

Open any folder and type this command “pip install openai requests==2.29.0 urllib3==1.26.16 -t python” this will install pip with these specific versions of requests and urllib3

Please :heart: if this saved your time