简体   繁体   English

lambda 层中没有可用的包 zbar

[英]No package zbar available in lambda layer

trying to create a layer for my lambda function which uses the pyzbar library, which requires the zbar shared library as dependency, to be downloaded separately, and can't be installed with pip.试图为我的 lambda 函数创建一个层,该函数使用 pyzbar 库,它需要 zbar 共享库作为依赖项,需要单独下载,并且不能使用 pip 安装。 My Dockerfile looks like this:我的 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"]

and my requirements.txt like this我的 requirements.txt 像这样

opencv-python-headless
pyzbar
pyzbar[scripts]

I'm getting the error我收到错误

No package zbar available没有可用的包 zbar

I'm getting the same error when I replace "zbar" with a number of other package names, eg libzbar0, libzbar-dev, zbar-tools, etc当我将“zbar”替换为许多其他包名称时,我遇到了同样的错误,例如 libzbar0、libzbar-dev、zbar-tools 等

You tried to install您尝试安装
https://pypi.org/project/pyzbar/ with pip, rather than https://pypi.org/project/pyzbar/用 pip,而不是
https://anaconda.org/conda-forge/pyzbar with conda . https://anaconda.org/conda-forge/pyzbarconda

Pip is very good at quickly solving pure-python installs. Pip 非常擅长快速解决纯 python 安装问题。 Conda solves a different class of problems. Conda 解决了另一类问题。 Here, you wish to incorporate binaries from zbar into your project, and you have expressed some frustration with the pip approach.在这里,您希望将zbar中的二进制文件合并到您的项目中,并且您对 pip 方法感到有些失望。

Using a conda environment.yml file would be the natural way to express your requirements.使用 conda environment.yml文件将是表达您的要求的自然方式。 It will deal with obtaining platform-appropriate binaries for you, so you don't have to sweat the details.它将为您获取适合平台的二进制文件,因此您不必担心细节。

zbar is not included in the default amazon linux repo, so you need to add the epel repo. zbar不包含在默认的 amazon linux repo 中,因此您需要添加 epel repo。

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"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为自定义 package 添加 lambda 图层 - Add lambda layer for custom package 在 AWS Lambda 层中安装 Python Package - Installing Python Package in AWS Lambda Layer 使用 AWS lambda 内部有 package.json 层和 Z04A7DA3C5B04CAD85DA1EEBBB8Z5 层 - Using an AWS lambda that has a package.json inside with a Lambda layer 如何缩小 AWS Lambda 层的大 python package 层? - How to shrink large python package for AWS Lambda Layer? Sam local Invoke lambda 出现本地层错误“无法导入包” - Sam local Invoke lambda with local layer error “unable to import package” Lambda function package 尽管使用了依赖层但仍然很大 - Lambda function package still large despite using a layer for dependencies 如何使用 aws cli 将 aws lambda 层部署包上传到 s3 存储桶? - How to upload aws lambda layer deployment package to s3 bucket using aws cli? 使用 python 在 AWS lambda 中从部署包(作为层添加)调用.py 脚本 - Call .py script from deployment package(added as a layer)in AWS lambda using python 无服务器 AWS Lambda 层与 python 包不工作。 奇怪的 hash 添加到 package 名称 - Serverless AWS Lambda Layer with python packages not working. Weird hash added to package name 如何在 aws lambda 环境中为 node-oracledb 包设置层? - how to set up a layer for node-oracledb package in aws lambda environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM