Closed cmflynn closed 1 year ago
ended up resolving this by doing:
...
import sys
# aws lambda come pre-installed with boto libs that are not the same version as the one we package. this ensures
# we import the version we package.
sys.path.insert(0, "/app")
import aioboto3
...
where /app is the root of your lambda
Yeah, there's nothing much I can do about this as this is really a lambda problem.
Apparently in /var/runtime/bootstrap.py LAMBDA_TASK_ROOT should set that as the first in the path, though im not sure where that would get set.
I had the same error and I fixed it by choosing versions of dependencies that matched the ones in the python lambda runtime.
The versions in the runtime are:
boto3 = '1.20.32'
botocore = '1.23.32'
I ended up using
botocore ='~1.23.24'
aiobotocore = '~2.1.2'
as this was the closest fit I could get that poetry was happy with.
Description
aws lambda fails to import aioboto3 with the following error:
[ERROR] ImportError: cannot import name 'apply_request_checksum' from 'botocore.client' (/var/runtime/botocore/client.py)
What I Did
Using aioboto3<=9.3.0 is a workaround.
It appears that AWS uses their own versions of boto3 and botocore on their lambda image exec environment, that do match what pip freeze thinks should be installed on the actual docker image.
as a result, aiobotocore.client fails on
this is because botocore==1.23.32 does not have
apply_request_checksum
in its client.looking deeper at package version...
pip freeze says: boto3==1.24.59 botocore==1.27.59
(app.py, I run this lambda handler in aws env, to see whats actually installed at run time)
BUT in the aws lambda logs I get this:
pip freeze:
my requirements.txt for this image: