如何将 NumPy 导入到 AWS Lambda?

问题描述 投票:0回答:1

我在 AWS Lambda 上遇到 NumPy 1.25.1 导入错误,然后我尝试运行它。

我通过 AWS Web 客户端从 .zip 文件上传代码。

这是我用来创建图层的要求

charset-normalizer==3.2.0
contourpy==1.1.0
cycler==0.11.0
docopt==0.6.2
et-xmlfile==1.1.0
fonttools==4.41.0
idna==3.4
kiwisolver==1.4.4
numpy==1.25.1
packaging==23.1
Pillow==10.0.0
psutil==5.9.5
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2023.3
simpy==4.0.1
six==1.16.0
tzdata==2023.3
XlsxWriter==3.1.2
openpyxl==3.1.2
requests==2.31.0

Lambda 和 Layer 的运行时相同:

Python 3.11

错误信息:

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

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.11 from "/var/lang/bin/python3.11"
  * The NumPy version is: "1.25.1"

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'

Traceback (most recent call last):

我知道已经存在相同的问题,但我还没有看到与我的运行时和 NumPy 版本相同的问题。所以也许解决方案会有所不同

我尝试:

  • 将 NumPy 版本更改为 1.25.2 [同样问题]
  • 将运行时版本更改为Python 3.10/3.9/3.8 [urllib导入错误]
python python-3.x numpy aws-lambda python-import
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.