I created a layer for my Lambda functions so that I have all my dependencies in one place. When I run this locally, I have no issues. When I run it in Lambda, I get
Original error was: No module named 'numpy.core._multiarray_umath'
I do not use Numpy explicitly in my code, it is a dependency for Matplotlib and Pandas and thus gets installed when installing these libraries. I have tried everything I can think of with no success. I verified the versions of Python (3.9), Matplotlib (3.7.0), Pandas (1.5.3), and Numpy (1.24.2) are compatible. I have looked all over the internet and the solutions I find do not work for me. I have tried reinstalling my requirements.txt with the specific versions I use in my venv locally, I tried with no specific versions designated, I tried using the --upgrade option when installing with pip, per this similar question I tried running an ec2 instance (ubuntu) and building my layer specifically with python3.9 (the lambda runtime), and many other things.
For reference, here is a link to the module that is causing the issue. Granted, it works fine when cloned off of GitHub and run locally, the issue seems to be with Lambda's set up. Also, I use the same layer for my other functions (which do not use Matplotlib or Pandas) and they run just fine.
I feel like there is something about Lambda's environment I am not understanding. Any help in understanding this is greatly appreciated. I have spent 10+ hours trying to get this to work with no success.
Below is the whole traceback it gives me. I checked out the link they provide and couldn't find anything useful there but maybe I am overlooking something? Hoping this is a simple fix as this is the last major thing keeping me from finishing my WebApp.
`START RequestId: b675dac9-a101-4f2c-a3cf-beb4f17ff3f8 Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'results':
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "/var/lang/bin/python3.9"
* The NumPy version is: "1.24.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Traceback (most recent call last):END RequestId: b675dac9-a101-4f2c-a3cf-beb4f17ff3f8
REPORT RequestId: b675dac9-a101-4f2c-a3cf-beb4f17ff3f8 Duration: 24.03 ms Billed Duration: 25 ms Memory Size: 128 MB Max Memory Used: 40 MB Init Duration: 126.23 ms`
Wow, this was the solution. Thank you for this. I can't believe I spent 10 + hours so far for a minor setting done in the first step. On the bright side, I gained some good experience with Lambda layers, EC2, and VENVs in the process. Thank you!
You're welcome! If you get around to it, please hit "Accept" on my answer. Thank you.
Hi
What should I do to remove this same error We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following:
@Mayur, are you asking how this was solved? Just to make sure that the correct processor architecture, x86_64, was used when creating the Lambda function. Native code like numpy is architecure-specific.