Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda and Numpy Libraries - Importing the multiarray numpy extension module failed

Trying to successfully run numpy on AWS Lambda. The information I have read indicates that you need to use numpy libraries specifically compiled/compatible with AWS EC2.

Do do this I first followed the instruction to compile numpy on an ec2 instance, here:

Installing numpy on Amazon EC2

I then copied the newly built numpy into my Lambda application folder on my desktop, zipped up a Lambda deployment package containing the entire directory.

Upon running my Lambda function I still get this error:

Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try git clean -xdf (removes all files not under version control). Otherwise reinstall numpy.

Suggestion?

like image 747
Dave Avatar asked Sep 22 '17 21:09

Dave


1 Answers

Adding an answer for anyone who finds this old question.

Luckily, this problem has now been solved with Lambda Layer. AWS even provides a NumPy and SciPy layer. You can attach it directly to your Lambda in the web console or use this ARN arn:aws:lambda:us-east-1:668099181075:layer:AWSLambda-Python36-SciPy1x:2

like image 173
Milan Cermak Avatar answered Sep 21 '22 04:09

Milan Cermak