I'm trying to deploy a simple service to AWS Lambda (on Python 3.6) that requires PIL. I'm using the serverless framework, so to start I simply did pip3 freeze > requirements.txt on an ec2 instance with my code and all of the dependencies installed, and when I called the Lambda function I got the following error (from CloudWatch logs):
Unable to import module 'lambda_function': No module named 'PIL'
I then tried to install & package pillow manually by doing pip3 install pillow -t .vendor and added the following to my serverless.yml:
package:
include:
- .vendor/**
But I'm still getting the same error. Am I doing something wrong?
EDIT: It seems that not using the serverless architecture and instead packaging the dependencies myself fixed the issue. Why is this?