【发布时间】:2019-03-22 01:14:44
【问题描述】:
我在尝试将matplotlib 作为layer 添加到我的 Python 2.7 AWS Lambda 函数时遇到问题。
在Lambda execution environment 上,我正在尝试安装必要的库并按照here 的描述创建一个层。
我尝试过的事情:
首先,我pip installed matplotlib 进入虚拟环境,并复制了 lib 和 lib64 下的 site-packages 的内容。执行 lambda 函数时,我得到一个 No module named pkg_resources 异常。我还尝试使用 --target 选项安装所有依赖项到同一个文件夹。结果是一样的。
我读到here 可能是由于 setuptools 包过时造成的。当我更新 pip install --upgrade setuptools 然后尝试安装 matplotlib 时,我开始收到以下异常:
pkg_resources.DistributionNotFound: The 'pip==9.0.3' distribution was not found and is required by the application
最后我想到了用
安装 matplotlibsudo yum install python-matplotlib
然后按照here 的描述收集所需的包。但这并没有使 matplotlib 可以从 python shell 中导入,所以我猜它不能作为 Lambda 层工作。
感谢您的帮助。
P.S:在 AWS re:invent 上,这正是 demoed,但没有关于会话的详细信息:/
【问题讨论】:
标签: python-2.7 matplotlib aws-lambda amazon-linux