1
votes

I am trying to install a lambda function as shown on this blog...

https://www.obytes.com/blog/image-resizing-on-the-fly-with-aws-lambda-api-gateway-and-s3-storage

I followed these steps, uploaded the zip file and getting an error.

git clone https://github.com/obytes/resize_s3_images.git

cd resize_s3_images/

wget https://pypi.fcio.net/packages/14/41/db6dec65ddbc176a59b89485e8cc136a433ed9c6397b6bfe2cd38412051e/Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl

unzip Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl && rm Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl

zip -r resize_s3_images.zip .

When I try to test the function:

{ "errorMessage": "Unable to import module 'resize_s3_images': cannot import name '_imaging' from 'PIL' (/var/task/PIL/init.py)", "errorType": "Runtime.ImportModuleError" }

1

1 Answers

2
votes

Install pillow package with pip at this directory like this.

pip install Pillow -t .

Then remove existig zip and make again.

rm -rf resize_s3_images.zip

zip -r resize_s3_images.zip .

Import Image from pil like this

from PIL import Image

If you still have problem then use lambda layers or move code into '/tmp/dependencies/' directory using os.system('cp <folder_name> /tmp/dependencies/)