如何将NumPy导入AWS Lambda?

bkhjykvo  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(94)

我在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):
  • 我知道已经存在相同的问题,但我还没有看到与我相同的nump和NumPy版本.所以也许答案会不同 *

我试着:

  • 将NumPy版本更改为1.25.2 [相同问题]
  • 将Python版本更改为Python 3.10/3.9/3.8 [urllib导入错误]
ss2ws0br

ss2ws0br1#

AWS托管的Data-Wrangler Layer for Python Lambda函数包括NumPy。将其包含在Lambda函数中就像从托管层的目录中选择它一样简单。

相关问题