cryptography
cryptography copied to clipboard
getting errors installing or importing cryptography on AWS Lambda
- Versions of Python,
cryptography,cffi,pip, andsetuptoolsyou're using: Python 3.12 cffi-1.16.0 cryptography-42.0.8 pycparser-2.22 pip-24.1 setuptools-70.1.0 - How you installed
cryptographypip install cryptography - Clear steps for reproducing your bug
- install cryptography using pip, write test code
- test in dev local machine, it works without issue
- create the deployment package and upload it to AWS Lambda, getting error as below: { "errorMessage": "Unable to import module 'lambda_function': cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)", "errorType": "Runtime.ImportModuleError", "requestId": "6f31441e-ba2b-4de8-af7c-eeb7f07d6bd5", "stackTrace": [] } the lambda python runtime is 3.12, the same version as it on local machine
Did you follow the Lambda documentation? Particularly https://docs.aws.amazon.com/lambda/latest/dg/python-package.html
This issue has been waiting for a reporter response for 3 days. It will be auto-closed if no activity occurs in the next 5 days.
Did you follow the Lambda documentation? Particularly https://docs.aws.amazon.com/lambda/latest/dg/python-package.html
yeah I'm pretty sure the packaging is correct, other modules import works fine.
The error strongly indicates you have an incompatible compiled object in your deployment. Cryptography uses native code in addition to Python so it’s important to use the correct artifacts.