【问题标题】:Not able to add pandas in aws layer and getting error无法在 aws 层中添加熊猫并出现错误
【发布时间】:2020-12-02 10:27:31
【问题描述】:

我在 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"
}

【问题讨论】:

    标签: python pandas numpy aws-lambda aws-lambda-layers


    【解决方案1】:

    包的压缩包应该在 build 文件夹中完成,即使您将包安装在 site-packages 中 https://www.youtube.com/watch?v=zrrH9nbSPhQ - 有一些很好的步骤要遵循。

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

    【讨论】:

      猜你喜欢
      • 2021-10-12
      • 2019-03-06
      • 2014-11-07
      • 1970-01-01
      • 2017-09-14
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      • 2018-02-11
      相关资源
      最近更新 更多