I have a python file with a number of functions. Each of these functions takes a .csv file as input. Some of the functions return json and others are intended to return graphs made by pyplot. I have to send fetch request to this file from my Next.js web backend.
I have used aws lambda functions to achieve this. The functions returning json are working fine, but those returning graphs are taking too long and I am facing this error, although I have added a custom layer using a .zip file.
Response
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'matplotlib'",
"errorType": "Runtime.ImportModuleError",
"requestId": "",
"stackTrace": []
}
Function Logs
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'matplotlib'
Traceback (most recent call last):INIT_REPORT Init Duration: 3026.04 ms Phase: init Status: error Error Type: Runtime.Unknown
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'matplotlib'
Traceback (most recent call last):INIT_REPORT Init Duration: 42372.04 ms Phase: invoke Status: error Error Type: Runtime.Unknown
START RequestId: 4da62ba2-826e-4d85-8855-f9a2902ed814 Version: $LATEST
END RequestId: 4da62ba2-826e-4d85-8855-f9a2902ed814
REPORT RequestId: 4da62ba2-826e-4d85-8855-f9a2902ed814 Duration: 42407.92 ms Billed Duration: 42408 ms Memory Size: 128 MB Max Memory Used: 123 MB Status: error Error Type: Runtime.Unknown
Please help me solve this issue.