AWS Lambda:如何使用枕头库? [英] AWS Lambda : How to use Pillow library?

查看:100
本文介绍了AWS Lambda:如何使用枕头库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个AWS lambda函数,以创建上传图像的缩略图. 我的脚本在本地运行良好,我遵循了教程来部署我的函数,但是我对Pillow库有问题,确实在测试我的函数时,我可以看到以下日志:

I'm trying to create an AWS lambda function in order to create thumbnail of my uploaded images. My script is running well locally, I followed this tutorial to deploy my function but I have a problem with the Pillow library, indeed when I'm testing my function I can see this following log :

我发现了这个

I found this post with the same issue but in my case I can't execute command line on the machine.

推荐答案

您必须在Lambda软件包中包含libjpeg.so,但还需要对pip install 模块名称 "(而不是通过virtualenv)准备lambda软件包的,请执行以下操作:

You must include the libjpeg.so in your lambda package, but it will also require some tweaking with the patchelf utility. Assuming that you prepare the lambda package via "pip install module-name -t" (rather than via virtualenv), do the following:

cd into/your/local/lambda/package/dir
cp -L $(ldd PIL/_imaging.so|grep libjpeg|awk '{print $3}') PIL/
patchelf --set-rpath PIL PIL/_imaging.so
# zip, deploy and test the package

此脚本适用于Pillow版本3.2.0.

This script works for Pillow version 3.2.0.

关于patchelf:在Ubuntu下可以'apt install'版本,但是在其他Linux下,可能需要从源代码构建.

Regarding patchelf: under Ubuntu it can be 'apt install'ed, but under other Linuxes it may need to be built from source.

这篇关于AWS Lambda:如何使用枕头库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆