2

Unable to import module 'lambda_function': No module named 'bcrypt'

I get the above error when I import bcrypt in my python code on AWS Lambda

My Python version is 3.8 and I've added python bcrypt 3.2.0 as a layer to my lambda function. There tutorial I referred to add Layers to Lambda is here

The file structure for my bcrypt layer is ./python/bcryptfiles (bcryptfiles is my bcrypt package)

I initially included the bcrypt package as a folder adjecent to my lambda_function.py file, which solved bcrypt import issue. But when I invoked checkpw, I got the error module 'bcrypt' has no attribute 'checkpw'

Can someone please suggest a solution? I couldn't find questions related to python bcrypt in AWS Lambda, hence raise this issue.

Source of my python bcrypt package download here

1 Answer 1

1

As this bcrypt should be a library installed as a layer, you shouldn't need to add it adjacent to your lambda_handler.py file.

Also, you would probably need an amazon linux build (amazon linux 2 for python 3.8) to run it on this runtime.

One method that has helped me build unavailable packages in the past was this: https://github.com/lambci/docker-lambda

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the response. I resolved the issue in a similar manner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.