问题描述
我正在使用SearchFacesbyimage
的lambda函数,并且我正在使用此文档https://aws.amazon.com/blogs/machine-learning/build-your-own-face-recognition-service-using-amazon-rekognition/
I am using a lambda function of SearchFacesbyimage
And I am using this doc https://aws.amazon.com/blogs/machine-learning/build-your-own-face-recognition-service-using-amazon-rekognition/
我在哪里比较
from PIL import Image
我收到此错误 Unable to import module 'lambda_function': No module named PIL
推荐答案
我也遇到了同样的问题.您可以在此处执行两个步骤:手动打包和自动打包部署.
I also ran into this exact same problem. There are two steps that you can take here: manual versus automated packaging and deploying.
手动步骤将涉及创建正确的virtualenv并在该虚拟环境中安装依赖项.然后压缩所有内容并上传到AWS.
The manual step would involve creating the correct virtualenv and install dependencies in that virtual environment. Then zip everything and upload to AWS.
要使内容自动化,我总是喜欢使用无服务器框架来打包和部署Lambda函数.特别是python-requirements-plugin有助于打包.但是我必须指定以下内容来告诉框架在docker容器中构建,并且不要剥离任何库:
To automate stuff, I always prefer to use the Serverless framework to package and deploy Lambda functions. Specifically the python-requirements-plugin helps with packaging. But I do have to specify the following things to tell the framework to build within a docker container and don't strip any libraries:
custom:
pythonRequirements:
dockerizePip: true
strip: false
这篇关于AWS lambda无法导入模块"lambda_function":没有名为PIL的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!