Problems importing numpy in AWS Lambda function

Viewed 288

I have several lambda functions and know the drill in terms of building and exporting python libraries to be utilized on the lambda environment. Unfortunately i have run into problems with numpy.

So i have a EC2 environment (Amazon Linux AMI) running Python 3.6.0, which is equivalent to the Python version running on my Lambda function. I have built numpy==1.12.0. Which i have then exported to my Lambda function. Unfortunately i am getting following error on the function when invoking it:

START RequestId: e0f95294-c7a0-11e7-973e-7b655ecd81b6 Version: $LATEST
Unable to import module 'lambda': 
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.
1 Answers

I'm having the same problem. I figured out that it's a common problem right now. Temporarily, i advice you to take all the library compiled in your Python interpreter version. In your case Python3.6, then zip it. And load it into the directory of your lambda function. That's the only solution i found to solve the problem.

Zip the library using the shell command zip -9 -r dirname You'll need "-r" to zip recursively, and you'll need the "9" to compress the most you can.

GoodLuck!

Related