Member-only story

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

Luci Bro
2 min readJul 29, 2021

--

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

--

--

No responses yet

Write a response