【问题标题】:How to use layers to use opencv for lambdas using Python 3.9/M1如何使用层将 opencv 用于使用 Python 3.9/M1 的 lambda
【发布时间】:2023-01-04 10:58:56
【问题描述】:

我正在尝试按照本教程 (https://github.com/awslabs/lambda-opencv) 进行操作,但是在尝试测试我的 AWS lambda 函数(x86 架构)时,我总是遇到 numpy 错误。我把错误贴在下面:

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/var/lang/bin/python3.9"
  * The NumPy version is: "1.23.3"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'

使用 M1 macbook 运行 README 中的命令会影响事情吗?我也尝试过 pip3 将 cv2 (4.6.0.66) 和 numpy (1.23.3) 安装到压缩包中,但这仍然会产生相同的错误(功能使用 arm 架构)。我注意到,当我有一个 x86 架构的函数时,我可以使用来自 Klayers (https://github.com/keithrozario/Klayers) 的 arn 来克服 numpy 错误,但是我有一个 opencv 错误显示在这里:

Unable to import module 'lambda_function': /opt/python/lib/python3.9/site-packages/cv2/cv2.abi3.so: invalid ELF header

有谁知道如何获得使用图层的教程中的功能?任何帮助表示赞赏。

【问题讨论】:

  • this 有帮助吗?

标签: python amazon-web-services numpy opencv


【解决方案1】:

我有同样的问题。你能想出来吗?这是我的错误:

无法导入模块“lambda_function”:/opt/python/lib/python3.9/site-packages/cv2/cv2.abi3.so:无法打开共享对象文件:没有这样的文件或目录

Response
{
  "errorMessage": "Unable to import module 'lambda_function': /opt/python/lib/python3.9/site-packages/cv2/cv2.abi3.so: cannot open shared object file: No such file or directory",
  "errorType": "Runtime.ImportModuleError",
  "requestId": "e12403bb-08dd-468e-9a9c-e6baac69dd20",
  "stackTrace": []
}

Function Logs
START RequestId: e12403bb-08dd-468e-9a9c-e6baac69dd20 Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': /opt/python/lib/python3.9/site-packages/cv2/cv2.abi3.so: cannot open shared object file: No such file or directory

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    • 2021-09-27
    • 2022-11-03
    • 2022-07-21
    • 2022-01-17
    • 2016-02-08
    • 1970-01-01
    相关资源
    最近更新 更多