ryanjackson
ryanjackson

Reputation: 83

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. My Dockerfile looks like this:

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

opencv-python-headless
pyzbar
pyzbar[scripts]

I'm getting the error

No package zbar available

I'm getting the same error when I replace "zbar" with a number of other package names, e.g. libzbar0, libzbar-dev, zbar-tools, etc

Upvotes: 2

Views: 1579

Answers (3)

Juan Barros
Juan Barros

Reputation: 1

I just have the same problem but using the link https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm didn't work for me [Fedora remove the link :( ].

After searching a lot, I found other link to EPEL7 in the fedora people site and It works for me:

yum -y install https://fedorapeople.org/groups/repos/dchen/epel7-collection/epel-7/x86_64/epel-release-7-5.noarch.rpm

Upvotes: 0

J_H
J_H

Reputation: 20415

You tried to install
https://pypi.org/project/pyzbar/ with pip, rather than
https://anaconda.org/conda-forge/pyzbar with conda.

Pip is very good at quickly solving pure-python installs. Conda solves a different class of problems. Here, you wish to incorporate binaries from zbar into your project, and you have expressed some frustration with the pip approach.

Using a conda environment.yml file would be the natural way to express your requirements. It will deal with obtaining platform-appropriate binaries for you, so you don't have to sweat the details.

Upvotes: 1

jellycsc
jellycsc

Reputation: 12259

zbar is not included in the default amazon linux repo, so you need to add the 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"]

Upvotes: 2

Related Questions