#πŸ”’ Running python script on cloud

13 messages Β· Page 1 of 1 (latest)

ivory karma
#

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.

sterile hatchBOT
#

@ivory karma

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

high vessel
#

I probably can't help, except to state the obvious: have you told AWS lambda that your whatchamacallit needs to import matplotlib?

#

pretty sure you have to tell it that explicitly

ivory karma
ivory karma
barren lion
#

Is matplotlib in your requirements.txt? Does AWS use requirements.txt to install dependencies?

ivory karma
#

I haven't made a requirements.txt file. Just created a function on aws and assigned it an api.
I have used aws for the first time, so I am not sure about it.

Should I ask this question on an aws server?

barren lion
#

You would likely have more luck on an AWS server, since this seems to be more of a DevOps/Cloud issue than a code one.

ivory karma
barren lion
#

You're welcome. Good luck.

sterile hatchBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.