0

在 lambda 函数中导入 pandas/numpy 时出现错误:

我添加了 pandas/numpy 作为 aws 层,我也以同样的方式添加了 pymysql,它工作正常。

在 Windows 10 上工作,
在 lambda 中使用相同的 python3.7 也
使用 pip install pandas -t
在目录中构建 zip 包 - python\lib\python3.7\site-packages

{
  "errorMessage": "Unable to import module 'lambda_function': \n\nIMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!\n\nImporting the numpy C-extensions failed. This error can happen for\nmany reasons, often due to issues with your setup or how NumPy was\ninstalled.\n\nWe have compiled some common reasons and troubleshooting tips at:\n\n    https://numpy.org/devdocs/user/troubleshooting-importerror.html\n\nPlease note and check the following:\n\n  * The Python version is: Python3.7 from \"/var/lang/bin/python3.7\"\n  * The NumPy version is: \"1.19.1\"\n\nand make sure that they are the versions you expect.\nPlease carefully study the documentation linked above for further help.\n\nOriginal error was: No module named 'numpy.core._multiarray_umath'\n",
  "errorType": "Runtime.ImportModuleError"
}
4

1 回答 1

0

即使您在站点包 https://www.youtube.com/watch?v=zrrH9nbSPhQ中安装包,包的 zip 也应该在 build 文件夹中完成- 有一些很好的步骤可以完成。

Pandas 可能是一个巨大的 zip 文件,lambda 层可能不支持。您可能需要检查 pandas-example pandas-xlrd。

于 2020-08-28T01:05:42.380 回答