boto3 : AttributeError: 'module' 对象没有属性 'ressource

-3 python boto3

我正在尝试使用 boto3 与我的 AWS 基础设施进行交互。当我直接从 python CLI (v 3.6.1) 使用 boto3 时,以下代码正在工作:

import boto3
client = boto3.ressource('iam')
print(client.User('myusername').arn)
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试从 python 脚本文件 (test.py) 使用它,我会收到以下错误:

$ python test.py
Traceback (most recent call last):
File "test.py", line 5, in <module>
client = boto3.ressource('iam')
AttributeError: 'module' object has no attribute 'ressource'
Run Code Online (Sandbox Code Playgroud)

提前谢谢你

gjt*_*ton 8

对我来说看起来像一个简单的错字。

尝试

boto3.resource('iam')
Run Code Online (Sandbox Code Playgroud)

代替

boto3.ressource('iam')
Run Code Online (Sandbox Code Playgroud)

来源:https : //boto3.readthedocs.io/en/latest/reference/services/iam.html#service-resource