aws-lambdapython-3.7

Unable to import module 'lambda_function': cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust' (unknown location)


I have a python script generating a CSR from a CBOR. It works fine on device locally. But when I try making it a lambda function and executing it on AWS, I got an error message "Unable to import module 'lambda_function': cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust'(unknown location)".

I'm not using layer, I just installed the modules inside the deployable package. I can confirm that the exceptions.pyi is located inside cryptography.hazmat.bindings._rust. I don't know what's causing this issue. Can anyone give me some guidance, thank you.

enter image description here


Solution

  • Spent a few days trying to fix the importing issue but still no luck. I ended up deploying the python lambda function with container image, all problem solved.

    I followed the instructions here https://docs.aws.amazon.com/lambda/latest/dg/python-image.html#python-image-instructions.