尝试为我的 lambda 函数创建一个使用 pyzbar 库的层,该函数需要 zbar 共享库作为依赖项,需要单独下载,并且无法使用 pip 安装。我的 Dockerfile 如下所示:
FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt .
COPY lambda_function.py .
RUN pip install --upgrade pip &&\
pip install -r requirements.txt &&\
yum makecache &&\
yum -y install zbar
CMD [ "lambda_function.lambda_handler"]
我的requirements.txt是这样的
opencv-python-headless
pyzbar
pyzbar[scripts]
我收到错误
No package zbar available
当我将“zbar”替换为许多其他包名称时,例如,我遇到了相同的错误libzbar0、libzbar-dev、zbar-tools 等
最佳答案
zbar
未包含在默认的 amazon Linux 存储库中,因此您需要添加 epel 存储库。
FROM public.ecr.aws/lambda/python:3.8
COPY requirements.txt .
COPY lambda_function.py .
RUN pip install --upgrade pip &&\
pip install -r requirements.txt &&\
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm &&\
yum makecache &&\
yum -y install zbar
CMD [ "lambda_function.lambda_handler"]
关于aws-lambda - lambda 层中没有可用的包 zbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72850004/