Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aws Lambda: Python function with Pandas dependency

How to deploy to python function which has the dependency on external libraries?
For example, I am trying to deploy to a data-analysis python function. When I try to test the python function from the lambda console, I get:
Unable to import module 'lambda_function': No module named pandas

I am totally new to Aws Lambda

Is there a linux box on which Lambda functions run where I can install these libraries?

like image 369
Himanshu Yadav Avatar asked Sep 05 '25 22:09

Himanshu Yadav


2 Answers

You need to create a deployment package as detailed here: http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html#deployment-pkg-for-virtualenv

This just means bundling the contents of site-packages for the environment you're developing on into the deployment package together with the lambda python script into a zip that is uploaded.

like image 60
Oluwafemi Sule Avatar answered Sep 09 '25 01:09

Oluwafemi Sule


If you new to Lambda deployment, you might want check this tutorial (I wrote), which covers the most common pitfalls. And gives you a script as well to automate the entire process.

like image 36
joarleymoraes Avatar answered Sep 09 '25 01:09

joarleymoraes