I want to use matplotlib to create image files in an AWS Lambda function. Since my system does not run the same version of Linux that Lambda uses, I received the guidance to download a wheel (.whl file) from the matplotlib website. I downloaded matplotlib-3.3.3-cp36-cp36m-manylinux1_x86_64.whl https://files.pythonhosted.org/packages/d2/43/2bd63467490036697e7be71444fafc7b236923d614d4521979a200c6b559/matplotlib-3.3.3-cp36-cp36m-manylinux1_x86_64.whl
to the folder where I am creating my deployment package.
First of all, I there are many wheel files and it is not clear if this is the correct one to use. Second, it doesn't work.
THen I upacked the wheel with the command
wheel unpack *.whl
This produced a directory with the matplotlib package in it.
My main function is
import matplotlib.pyplot
def lambda_handler(event, context):
return
I gave the commands
zip -r my-deployment-package.zip .
zip -g my-deployment-package.zip lambda_function.py
and uploaded the zip to an s3 bucket. Then I used the "aws lambda update-function-code..." command to update the lambda function. When I deploy and test, I get the error: "Unable to import module 'lambda_function': No module named 'matplotlib'"
Thinking that the matplotlib module is not there (perhaps I need to do something with the whl file or put it in a different place), i activated my virtual environment and started the python interpreter. Trying to import matplotlib, I get "module not found." Trying to use pip install on the matplotlib directory, it complains that there is no setup.py:
$ pip install --no-index --find-links=. matplotlib-3.3.3/
ERROR: Directory 'matplotlib-3.3.3/' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
How can I get the module to be recognized?