AWS Lambda : How to use Pillow library?
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
This script works for Pillow version 3.2.0.
Regarding patchelf
: under Ubuntu it can be 'apt install'
ed, but under other Linuxes it may need to be built from source.