When trying to run my code, which contained urllib3 HTTPResponse.json() method, in AWS Lambda, Python 3.12 runtime, I got an error HTTPResponse object has no attribute json.
It was running fine locally.
After I changed response.json() to json.loads(response.data) it started working.
I wanted to avoid bundling, so I wanted to use library that is contained in AWS Lambda runtimes. Apparently the urllib3 version included in Python 3.12 runtime is some older one.
Is there a way to tell which modules in which versions are contained in given python lambda runtime?
I've found a list and a tool here, which probably can give me an answer after some work, but I wonder if there's any 'ready-made' resource?
You can find out the libraries which are included in the python runtime by spinning up a super simple lambda:
import json
from importlib.metadata import packages_distributions, version
def lambda_handler(event, context):
installed = [{"name": pkg, "version": version(pkg) } for pkgs in packages_distributions().values() for pkg in pkgs]
return {
'statusCode': 200,
'body': installed
}
This will give you the following output, from which you can ascertain the various versions of the various libraries:
{
"statusCode": 200,
"body": [
{
"name": "pip",
"version": "23.2.1"
},
{
"name": "pip",
"version": "23.2.1"
},
{
"name": "simplejson",
"version": "3.17.2"
},
{
"name": "simplejson",
"version": "3.17.2"
},
{
"name": "awslambdaric",
"version": "2.0.10"
},
{
"name": "awslambdaric",
"version": "2.0.10"
},
{
"name": "awslambdaric",
"version": "2.0.10"
},
{
"name": "awslambdaric",
"version": "2.0.10"
},
{
"name": "botocore",
"version": "1.34.42"
},
{
"name": "botocore",
"version": "1.34.42"
},
{
"name": "boto3",
"version": "1.34.42"
},
{
"name": "boto3",
"version": "1.34.42"
},
{
"name": "s3transfer",
"version": "0.10.0"
},
{
"name": "s3transfer",
"version": "0.10.0"
},
{
"name": "jmespath",
"version": "1.0.1"
},
{
"name": "jmespath",
"version": "1.0.1"
},
{
"name": "python-dateutil",
"version": "2.8.2"
},
{
"name": "python-dateutil",
"version": "2.8.2"
},
{
"name": "six",
"version": "1.16.0"
},
{
"name": "six",
"version": "1.16.0"
},
{
"name": "urllib3",
"version": "1.26.18"
},
{
"name": "urllib3",
"version": "1.26.18"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With