我只是想在我的 Python 3.8 Lambda 中使用 PIL。
我正在尝试以下步骤:
cd /mydir
git clone https://github.com/hidekuma/lambda-layers-for-python-runtime.git
cd lambda-layers-for-python-runtime
mkdir dist
docker-compose up --build
- 基于此指南:https ://www.splunk.com/en_us/blog/cloud/sharing-code-dependencies-with-aws-lambda-layers.html
aws lambda publish-layer-version --layer-name ImageStorageDependencies
--description "A Python 3.8 runtime with PIL and boto3 installed." --license-info "MIT" --zip-file fileb://output.zip --compatible-runtimes python3.7 python3.8 --region us-east-2
然后我在 Lamda 配置中选择我的层,但是当我运行此代码时:
import json
import boto3
import io
from PIL import Image
def lambda_handler(event, context):
#etc
...我得到错误:
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': cannot import name '_imaging' from 'PIL'
我到底哪里错了?!?