Member-only story

Add Pandas and NumPy Python to AWS Lambda Layers (Python 3.7 | 3.8)

Luci Bro

AWS Lambda Layers with NumPy and Pandas by Aman Khanakia

After searching around for a few hours, I cannot seem to find what I’m looking for and the documentation on this subject is non-existent.

I needed access to the package in a lambda function however I have been unsuccessful finding the Pandas and NumPy packages for usage in a Lambda function.

So i decided to build the libraries myself to support the Amazon Linux 2 arch.

Problem:
How use Pandas and NumPy with Lambda functions (Python 3.7 or Python 3.8)?

There are no default Pandas and NumPy packages in AWS Lambda. You can have a look at AWS Lambda execution environment and all available libraries here.

Let’s create AWS Lambda function with code below:

import json
import pandas as pd
def lambda_handler(event, context):
pd.show_versions()
return

If you run this function you will get the following error:

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

Solution:

  1. Click here to download the

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response