当我简单地运行以下代码时,总是会出现此错误。
s3 = boto3.resource('s3')
bucket_name = "python-sdk-sample-%s" % uuid.uuid4()
print("Creating new bucket with name:", bucket_name)
s3.create_bucket(Bucket=bucket_name)
我已将凭证文件保存在
C:\Users\myname\.aws\credentials
,Boto应该从那里读取我的凭据。
我的设置错了吗?
这是的输出boto3.set_stream_logger('botocore', level='DEBUG')
。
2015-10-24 14:22:28,761 botocore.credentials [DEBUG] Skipping environment variable credential check because profile name was explicitly set.
2015-10-24 14:22:28,761 botocore.credentials [DEBUG] Looking for credentials via: env
2015-10-24 14:22:28,773 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file
2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: config-file
2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: ec2-credentials-file
2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: boto-config
2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: iam-role
HOME
,以点C:\Users\myname
或设置AWS_SHARED_CREDENTIALS_FILE
直接指向您的证书文件。
botocore.exceptions.NoRegionError: You must specify a region.
*我的配置文件↓与我的credentails位于同一文件夹中。 [default] ap-northeast-1
boto3.set_stream_logger('botocore', level='DEBUG')
在代码之前添加来发布调试输出吗?它将显示在哪里寻找凭证。