Have a look at this: https://repost.aws/knowledge-center/lambda-python-package-compatible
Essentially it mentions yo specify platform flag when installing dependencies, as certain libraries, if installed locally from windows, will conflict as they are expected with Linux binaries.
Hope it helps ;)
AWS Lambda doesn't provide the cryptography library for Python so you have to package the library with your Lambda function, which means you have to package/compile it somewhere outside Lambda and then import it into Lambda. I recommend you package the libraries inside the Amazon Linux-based EC2 instance as the versions will be compatible. I have faced a similar issue and got it fixed by getting all the library files inside the Amazon Linux-based EC2 instance.
Using Docker is another good solution to ensure that you have the same environment on both your local machine and the Lambda environment. Essentially, you will create a Docker container that replicates the Lambda environment, including the necessary dependencies such as pysftp and cryptography. You can then use this container to run your Lambda function, which should resolve the dependency issues.
- Accepted Answerasked 2 years ago
- Accepted Answerasked a year ago
- How do I resolve the "Unable to import module" error that I receive when I run Lambda code in Python?AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 8 months ago
- How do I update the AWS CloudFormation cfn-response module for AWS Lambda functions running on Python 2.7/3.6/3.7?AWS OFFICIALUpdated 3 years ago
- EXPERTpublished 8 days ago
- EXPERTpublished 9 months ago