I am trying to deploy a python function with numpy dependency.
Ran pip install numpy -t . in my project directory. Got the following message: Installing collected packages: numpy Successfully installed numpy-1.12.1
Project folder has numpy and numpy-1.12.1.dist-info directories. handler.py function is very straightforward.
{
"errorMessage": "Unable to import module 'handler'"
}
--------------------------------------------------------------------
START RequestId: 510e1b7f-42f1-11e7-b438-9dedd68ec099 Version: $LATEST
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 your local operating system? While I haven’t come across this answer personally, it looks like you might’ve uploaded .pyc files, which are probably not going to work on AWS Linux.
.pyc files are compiled bytecode, and so only work on the platform they were compiled on. When they’re getting packaged up and pushed to Lambda, they’re no long on the same platform (i.e. OSX) they were compiled on.
You likely haven’t built the packages on the right architecture. I have a blog post which goes through this in more detail and also covers how to correctly setup your path so that your code can import the libraries.