我目前在将库导入pandas我的 AWS Lambda 函数时遇到问题。我尝试了两种情况。
使用 my 将 pandas 直接安装到一个文件夹中
lambda_function并上传压缩文件。使用上传的 zip 文件创建一个层,其结构如下:
- python
- lib
- python3.8
- site-packages
- all the pandas packages here
我lambda_function的只是:
import json
import pandas as pd
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
这是我的错误:
START RequestId: 9e27641e-587b-4be2-b9be-c9be85007f9e Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'main': Unable to import required dependencies:
numpy:
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.8 from "/var/lang/bin/python3.8"
* The NumPy version is: "1.21.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'
还有其他方法吗?我不想使用 Docker 来完成这项任务。谢谢!