Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS lambda throwing import error because of URLLIB

Im running a python script on aws lambda and its throwing the following error.

 {
   "errorMessage": "Unable to import module 'app': urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.0.2k-fips  26 Jan 2017. See: https://github.com/urllib3/urllib3/issues/2168",
   "errorType": "Runtime.ImportModuleError",
   "stackTrace": [] }

It was running perfectly an hour ago , and even after I have made no deployments , it seems to be failing.

my python version is 3.7. and Im only using urllib to parse and unquote urls . namely

from urllib.parse import urlparse

and

from urllib.parse import unquote

like its mentioned in the GitHub url I can upgrade my python version, but doing so would break other things. Are there any alternative librries I can use to get the same result?

from the GitHub link , it shows urllib no longer supports OpenSSL<1.1.1 but somehow some of our higher environments the same scripts is running without issues.

like image 838
Devarshi Goswami Avatar asked Mar 08 '26 18:03

Devarshi Goswami


2 Answers

specifying my urllib3 to 1.26.15 in the requirement.txt file based on this https://github.com/urllib3/urllib3/issues/2168#issuecomment-1535838106 thread fixed this error.

like image 53
Devarshi Goswami Avatar answered Mar 10 '26 08:03

Devarshi Goswami


Upgrade you AWS Lambda function runtime to Python 3.10 and it should work.

like image 44
Sharhabeel Hamdan Avatar answered Mar 10 '26 08:03

Sharhabeel Hamdan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!