I am having trouble trying to add matplotlib
as a layer to my Python 2.7 AWS Lambda function.
On the Lambda execution environment, I am trying to install the necessary libraries and create a layer as described here.
Things I've tried:
First, I pip install
ed matplotlib into a virtual environment and copied the contents of the site-packages under lib and lib64. When the lambda function is executed, I get a No module named pkg_resources
exception. I also tried installing with the --target
option to install all dependancies to the same folder. The result was the same.
I read here that it may be due to outdated setuptools package. When I did an update pip install --upgrade setuptools
and then tried to install matplotlib I started getting the following exception:
pkg_resources.DistributionNotFound: The 'pip==9.0.3' distribution was not found and is required by the application
Finally I thought of installing matplotlib with
sudo yum install python-matplotlib
and then collect the required packages as described here. But this did not make matplotlib importable from within the python shell, so I guess it won't work as a Lambda layer.
Thanks for any help.
P.S: At AWS re:invent, exactly this was demoed but there are no details on the session :/