Getting this error from my python script whenever I run a test
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'PIL'",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
This code should take an input from an aws s3 bucket and transform it to a vangogh painting, then send it back to another s3 bucket.
import boto3
import os
import sys
import uuid
from PIL import Image
import PIL.Image
s3_client = boto3.client('s3')
def vangogh_image(image_path, transformation_path):
with Image.open(image_path).convert('RGB') as image:
image.filter('VAN_GOGH')
image.save(transformation_path)
def handler(event, context):
for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = record['s3']['object']['key']
download_path = 'temp/{}{}'.format(uuid.uuid(), key)
upload_filename = '/temp/vangogh-{}'.format(key)
s3_client.download_file(bucket, key, download_path)
vangogh_image(download_path, upload_filename)
s3_client.upload_file(upload_filename, '{}-vangigh'.format(bucket), key)