AttributeError:遵循 boto3 快速入门时,模块“botocore”没有属性“session”

Sli*_*mak 6 python aws-cli botocore boto3

我遵循 boto3 快速入门说明,我可以运行import boto3,但是当我尝试执行任何基本命令时,就像db = boto3.resource('dynamodb')我得到的

Traceback (most recent call last):

  File "<ipython-input-144-424c27c1bae1>", line 1, in <module>
    botocore.session.get_session()

AttributeError: module 'botocore' has no attribute 'session'
Run Code Online (Sandbox Code Playgroud)

凭证和配置文件看起来不错,我尝试重新安装 awscli 和 boto3 但没有帮助。我不明白这是什么问题。

小智 3

from botocore.session import Session

session = Session()
Run Code Online (Sandbox Code Playgroud)

使用上面的代码而不是使用

session = botocore.session.get_session()
Run Code Online (Sandbox Code Playgroud)

botocore 1.19.57 文档https://botocore.amazonaws.com/v1/documentation/api/latest/index.html#how-do-i-update-my-code