By using AWS re:Post, you agree to the Terms of Use

How to add python libraries to lambda using the CDK?


I want to use a library in my lambda function that was created by the CDK.

I did the following, without success:

  1. add the library to my requirements.txt file


  2. import the library in my lambda function

    from PIL import Image

  3. install it and deploy

    source .env/bin/activate pip install -r requirements.txt cdk deploy`

Many thanks for any hints!

asked 2 years ago285 views
1 Answer
Accepted Answer

You should have a look at the aws-lambda-python module:

It's still experimental and needs docker, but it will take care of your requirements.txt.

The same exists for nodejs just in case (

profile picture
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions