Janzaib M Baloch
Janzaib M Baloch

Reputation: 1353

Lambda Won't Detect The Layer

I have a python3.8, and I created a new folder and installed pandas in it using

pip3 install pandas -t .

Next thing - zipped the folder (the zipped folder is 38Mb), and uploaded to s3.

Created a Layer and added the s3 path of zip file in it (also set the runtime env to python3.8 here)

Next I created a lambda function with python3.8 and test its skeleton first and it worked.

Added the layer to the lambda function and imported pandas. And now when I run the test, it does not detect pandas and gives me Module Not Found error.

What can I be doing wrong here?

Upvotes: 1

Views: 2679

Answers (2)

charrison
charrison

Reputation: 857

There's now a managed layer that includes Pandas, so you don't need to create your own. It's called "AWS SDK for pandas" (aka awswrangler, formerly "AWS data wrangler"). You can add it to your AWS Lambda function by going Lambda > Layers > Add layer > AWS layers, then selecting AWSSDKPandas-Python311 (or similar) from the drop-down list.

Upvotes: 1

Subhashis Pandey
Subhashis Pandey

Reputation: 1538

Did you created a folder named python and put all the package files inside it? Also another supporting package Pytz is required to run panda in lambda. I use MAC OSX to create the zip file but the root folder needs to be named as "python".

The creation of the zip file is little bit lengthy to describe here, I suggest you to go through this document. Also naming convention is equally important. I think if you follow the document and create the zip file and upload it directly (or via S3) to create lambda layer then it will definitely work.

Upvotes: 3

Related Questions