![](/img/trans.png)
[英]Boto3 Error in AWS SDK: botocore.exceptions.NoCredentialsError: Unable to locate credentials
[英]botocore.exceptions.NoCredentialsError: Unable to locate credentials
我嘗試將Amazon AWS DynamoDB與python結合使用。 首先,我將通過亞馬遜推薦這本指南: http : //docs.aws.amazon.com/de_de/amazondynamodb/latest/gettingstartedguide/GettingStarted.Python.01.html
然后我運行亞馬遜代碼我得到錯誤:botocore.exceptions.NoCredentialsError:無法找到憑據
我擁有的憑據是“〜/ .aws / credentials”,它們看起來像這樣:
[profile-name]
aws_access_key_id=XXXX
aws_secret_access_key=YYYYYYY
我還嘗試設置包含的condign文件
[profile profile-name]
aws_access_key_id=XXXX
aws_secret_access_key=YYYYYYY
在我的IntelliJ應用程序中,一切都可正常使用此憑據。 它剛剛與PyCharm。
我也設置了這個記錄器,但這些信息對我幫助不大:
boto3.set_stream_logger('botocore', level='DEBUG')
調試信息是:
2016-05-04 11:58:18,162 botocore.credentials [DEBUG] Skipping environment variable credential check because profile name was explicitly set.
2016-05-04 11:58:18,162 botocore.credentials [DEBUG] Looking for credentials via: env
2016-05-04 11:58:18,162 botocore.credentials [DEBUG] Looking for credentials via: assume-role
2016-05-04 11:58:18,162 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file
2016-05-04 11:58:18,163 botocore.credentials [DEBUG] Looking for credentials via: config-file
2016-05-04 11:58:18,163 botocore.credentials [DEBUG] Looking for credentials via: ec2-credentials-file
2016-05-04 11:58:18,163 botocore.credentials [DEBUG] Looking for credentials via: boto-config
2016-05-04 11:58:18,163 botocore.credentials [DEBUG] Looking for credentials via: aim-role
最后:我的代碼(與教程相同,只是調試器):
from __future__ import print_function # Python 2/3 compatibility
import boto3
boto3.set_stream_logger('botocore', level='DEBUG')
dynamodb = boto3.resource('dynamodb', region_name='eu-central-1', endpoint_url="http://localhost:8000")
table = dynamodb.create_table(
TableName='Movies',
KeySchema=[
{
'AttributeName': 'year',
'KeyType': 'HASH' #Partition key
},
{
'AttributeName': 'title',
'KeyType': 'RANGE' #Sort key
}
],
AttributeDefinitions=[
{
'AttributeName': 'year',
'AttributeType': 'N'
},
{
'AttributeName': 'title',
'AttributeType': 'S'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
print("Table status:", table.table_status)
編輯:如果我更改我的憑據[profile-name]部分du [默認]我得到一個連接錯誤。
嘗試從您的代碼中取出endpoint_url。 不知道為什么,但為我工作:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.