cryptography icon indicating copy to clipboard operation
cryptography copied to clipboard

getting errors installing or importing cryptography on AWS Lambda

Open wgn1993 opened this issue 1 year ago • 2 comments

  • Versions of Python, cryptography, cffi, pip, and setuptools you'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 cryptography pip install cryptography
  • Clear steps for reproducing your bug
  1. install cryptography using pip, write test code
  2. test in dev local machine, it works without issue
  3. 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

wgn1993 avatar Jun 24 '24 08:06 wgn1993

Did you follow the Lambda documentation? Particularly https://docs.aws.amazon.com/lambda/latest/dg/python-package.html

alex avatar Jun 24 '24 10:06 alex

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.

github-actions[bot] avatar Jun 28 '24 00:06 github-actions[bot]

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.

wgn1993 avatar Jul 02 '24 07:07 wgn1993

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.

reaperhulk avatar Jul 02 '24 07:07 reaperhulk