在使用Python 3.12和AWS Lambda时,我尝试运行Redis,但遇到了一个错误,提示未识别的库。
很难相信Lambda没有将Redis作为原生库集成。我是否需要手动上传Redis库,或者它可能以另一个名称存在?
我的代码如下:
import json
import redis
def lambda_handler(event, context):
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
遇到的错误信息是:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'redis'",
"errorType": "Runtime.ImportModuleError",
"requestId": "xxxx-xxx-xxxx-xxxx-xxx",
"stackTrace": []
}