简体   繁体   English

Windows Python 包与亚马逊 Linux 不兼容?

[英]Windows Python packages not compatible with Amazon Linux?

I'm creating a layer for my lambda function by installing the dependencies locally, zipping the folder, and uploading it to S3.我正在为我的 lambda function 创建一个层,方法是在本地安装依赖项,压缩文件夹并将其上传到 S3。 To ensure the packages are compatible with Lambda runtimes, I'm installing the packages like this (per the docs)为了确保这些包与 Lambda 运行时兼容,我正在安装这样的包(根据文档)

pip install \
    --platform manylinux2014_x86_64 \
    --target=my-lambda-function \
    --implementation cp \
    --python 3.8 \
    --only-binary=:all: --upgrade \
    packagename

This works for all but one package, pyzbar, which, per its docs,这适用于除一个 package pyzbar 之外的所有设备,根据其文档,

The zbar DLLs are included with the Windows Python wheels. zbar DLL 包含在 Windows Python 车轮中。 On other operating systems, you will need to install the zbar shared library.在其他操作系统上,您需要安装 zbar 共享库。

Linux: sudo apt-get install libzbar0 Linux:sudo apt-get install libzbar0

Mac OS X: brew install zbar Mac OS X:冲泡安装 zbar

pyzbar works locally, but I can't install the shared library on Windows, so I'm getting pyzbar 在本地工作,但我无法在 Windows 上安装共享库,所以我得到了

ImportError: Unable to find zbar shared library ImportError: 找不到 zbar 共享库

when I try to run the lambda.当我尝试运行 lambda 时。 What's the best way to solve this?解决这个问题的最佳方法是什么?

The easiest way to do that is to download the library from pypi and then unzipped the file.最简单的方法是从 pypi 下载库,然后解压缩文件。 Then, you must put the file in a folder called "python" and then, you have to zipp the folder nad upload to a layer.然后,您必须将文件放在名为“python”的文件夹中,然后,您必须压缩文件夹并上传到图层。 It must works.它必须有效。

You need to install the zbar library on Amazon Linux as a system dependency before you do pip install pyzbar .在执行pip install pyzbar之前,您需要在 Amazon Linux 上安装 zbar 库作为系统依赖项。 The pyzbar package does not include a precompiled zbar library on Linux. pyzbar package 不包括 Linux 上的预编译 zbar 库。

Amazon Linux 2 is based on Red Hat, so it uses yum as a package manager, not apt-get . Amazon Linux 2 基于 Red Hat,因此它使用yum作为 package 管理器,而不是apt-get

You'll need to install the zbar package in Amazon, I don't know the exact package name to use in Amazon Linux, but you're going to need to install it with something like yum install zbar .您需要在 Amazon 中安装 zbar package,我不知道要在 Amazon Linux 中使用的确切 package 名称,但是您需要yum install zbar

Alternatively, if you can't make zbar works in Red Hat/Amazon Linux 2, you might want to use a container-based lambda, and use a Ubuntu or Debian base image, as they're the Linux distro that's officially supported by zbar. Alternatively, if you can't make zbar works in Red Hat/Amazon Linux 2, you might want to use a container-based lambda, and use a Ubuntu or Debian base image, as they're the Linux distro that's officially supported by zbar .

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM