how to import numpy and pandas inside aws lambda function?

0 votes

i need to process csv file using numpy and pandas , i could do it in local machine its running as a expected manner then i am trying to do the same thing in aws lambda function with the same code i was used in my local machine.i am trying to import numpy inside my aws lambda function but error was thrown as Unable to import module 'aws_lambda_demo/lambda_function': No module named 'numpy'. then i create a zip file with aws lambda function along with numpy package after that also facing same issue Unable to import module 'aws_lambda_demo/lambda_function': No module named 'numpy'. Notes: i kept my csv files in s3 storage .any help will be appreciated . thanks in advance.

Sep 17, 2018 in AWS by bug_seeker
• 15,360 points
2,489 views

1 answer to this question.

0 votes

The problem is that your local numpy and pandas are compiled for the local machine's architecture. Since AWS Lambda uses custom Linux, they are probably not compatible.

So if you want to use them, you have two choices:

  • Compile dependencies on EC2 instance which uses the same Amazon Linux version as AWS Lambda and create a deployment package.

  • Use one of the precompiled packages from here

answered Sep 17, 2018 by Priyaj
• 57,300 points

Dude... i followed the same... but there's use... of this way... https://www.thetechnologyupdates.com/aws-lambda-layers-tutorial/?unapproved=812&moderation-hash=cd0a7d0bbf3a7f3d924c0860a35945a3#comment-812 used this link and did the same ... but the error in lambda is 

Unable to import module 'lambda_function': Missing required dependencies ['numpy']

Hey @Sunil, follow these instructions:

upload your deployment package to the following repo:

git clone https://github.com/pbegle/aws-lambda-py3.6-pandas-numpy.git

Add your lambda_function.py to the zip file by running:

zip -ur lambda.zip lambda_function.py

Upload to S3 and source to lambda.

Hi The option to package the code using dependencies at the git hub location https://mflb.s3.ap-south-1.amazonaws.com/lambda.zip worked for me. Thanks for having these dependencies archived. Kudos

Related Questions In AWS

0 votes
1 answer

How to link AWS Lambda function to Amazon CloudWatch ?

In order to create Log Group and ...READ MORE

answered Jul 20, 2018 in AWS by datageek
• 2,440 points
237 views
0 votes
1 answer

How do I add python libraries to an AWS lambda function for Alexa?

As it is described in the Amazon ...READ MORE

answered Oct 23, 2018 in AWS by Archana
• 4,110 points
917 views
0 votes
1 answer

Is AWS Lambda code isolated to others and how?

AWS Lambda functions execute in a container ...READ MORE

answered Jan 21 in AWS by Fitinai
64 views
0 votes
1 answer

How to invoke the AWS lambda function from Java code

There are 2 methods in this class which should ...READ MORE

answered Feb 19 in AWS by Archana
• 5,580 points
1,285 views
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 57,300 points
2,344 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

how to import numpy and pandas inside aws lambda function?

The problem is that your local numpy ...READ MORE

answered Sep 14, 2018 in AWS by Priyaj
• 57,300 points
3,165 views