0

Installed numpy on my project folder using pip install numpy -t <project dir> command. I can see numpy and numpy-1.12.1.dist-info in the project directory.
But when I zip the directory and run it on Lambda I get
Unable to import module 'handler': Missing required dependencies ['numpy']

Unable to import module 'handler': 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.

What is wrong with my project?

Himanshu Yadav
  • 13,315
  • 46
  • 162
  • 291

1 Answers1

0

Check where your numpy is getting installed e.g $VIRTUAL_ENV/lib/python2.7/site-packages

After that follow these steps-

  cd $VIRTUAL_ENV/lib/python2.7/site-packages
  zip -r9 <path_to_your_lambda_function_zip>/awslambda.zip *

This will add all libs in the site-packages into the zip which you can upload directly

tom
  • 3,720
  • 5
  • 26
  • 48
  • Copied all python packages to project folder `cd /Library/Python/2.7/site-packages zip -r9 ~/Documents/my-service/awslambda.zip *` then zipped the project folder with python function and tested with lambda. Still getting the same error. – Himanshu Yadav May 27 '17 at 17:30
  • in the zip file check what are the libs installed ? and see if numpy is installed or not? are you using virtualenv ? – tom May 27 '17 at 17:37
  • Yes I tried using the virtualenv. If you check the error message, numpy is being recognized but there is some issue with how it is compiled. – Himanshu Yadav May 27 '17 at 17:53
  • I think you might be missing some numpy dependencies in that zip . I tried with zip -r9 /awslambda.zip * i.e. recursively copy all libs into zip and upload it to lambda and it is working for me . check https://stackoverflow.com/questions/34749806/using-moviepy-scipy-and-numpy-in-amazon-lambda – tom May 27 '17 at 18:34