Boto3 Error: botocore.exceptions.NoCredentialsError: Unable to locate credentials

后端 未结 12 2264
逝去的感伤
逝去的感伤 2020-11-30 23:00

When I simply run the following code, I always gets this error.

s3 = boto3.resource(\'s3\')
    bucket_name = \"python-sdk-sample-%s\" % uuid.uuid4()
    pri         


        
12条回答
  •  盖世英雄少女心
    2020-11-30 23:41

    I had the same issue and found out that the format of my ~/.aws/credentials file was wrong.

    It worked with a file containing:

    [default]
    aws_access_key_id=XXXXXXXXXXXXXX
    aws_secret_access_key=YYYYYYYYYYYYYYYYYYYYYYYYYYY
    

    Note that the profile name must be "[default]". Some official documentation make reference to a profile named "[credentials]", which did not work for me.

提交回复
热议问题