lambda python 3.9 运行时中的 botocore 包返回错误:“无法从 'botocore.docs' 导入名称“'DEPRECATED_SERVICE_NAMES'””

Ela*_*zan 20 python lambda boto3

我正在使用 Lambda Python 3.9 运行时。我还在 Lambda 中使用 boto3 和 botocore 默认包。

今天,我突然收到此错误:“无法从‘botocore.docs’导入名称‘DEPRECATED_SERVICE_NAMES’””。当我将 botocore 包添加到 lambda 运行时时,我才成功修复了它。我想避免它,因为它会使层的大小增加 10 MB。

有什么帮助吗?谢谢

den*_*lov 18

最新版本的 boto3 存在问题。您可以在此处查看该问题:https ://github.com/boto/boto3/issues/3648 。您需要在 lambda 中降级 boto3 版本。为此,请在您的requirements.txt 文件中包含较低版本的boto3。例如, boto3==1.26.90 对我有用。希望能帮助到你。


小智 -4

升级botocore应该可以解决问题。

pip install --upgrade botocore
Run Code Online (Sandbox Code Playgroud)