Python botocore.exceptions.NoCredentialsError:找不到凭据
我尝试将Amazon AWS DynamoDB与python结合使用。首先,我浏览了亚马逊的这本指南: 然后我运行Amazons代码,得到错误: botocore.exceptions.NoCredentialsError:找不到凭据 我拥有的凭据位于“~/.aws/credentials”,它们如下所示:Python botocore.exceptions.NoCredentialsError:找不到凭据,python,amazon-web-services,amazon-dynamodb,Python,Amazon Web Services,Amazon Dynamodb,我尝试将Amazon AWS DynamoDB与python结合使用。首先,我浏览了亚马逊的这本指南: 然后我运行Amazons代码,得到错误: botocore.exceptions.NoCredentialsError:找不到凭据 我拥有的凭据位于“~/.aws/credentials”,它们如下所示: [profile-name] aws_access_key_id=XXXX aws_secret_access_key=YYYYYYY 我还尝试设置一个conign文件,其中包括 [pr
[profile-name]
aws_access_key_id=XXXX
aws_secret_access_key=YYYYYYY
我还尝试设置一个conign文件,其中包括
[profile profile-name]
aws_access_key_id=XXXX
aws_secret_access_key=YYYYYYY
在我的IntelliJ应用程序中,使用此凭据一切正常。它刚才很有魅力
我还设置了此记录器,但这些信息对我帮助不大:
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
最后:我的代码(与教程相同,仅使用调试器):
编辑:如果我更改了凭据中的[profile name]部分du[default],我会收到一个连接错误。尝试从代码中删除endpoint\u url。不知道为什么,但对我有效:)我想你必须将其设置为
default
而不是profile name
。您的本地系统上是否运行dynamodb?@JanZeiseweis如果我将其更改为默认值,则会出现连接错误。不,dynamodb只是在was上运行,而不是在我的本地系统上运行。在本教程的先决条件中,您要学习的第一点是:在您的计算机上下载并运行dynamodb。有关更多信息,请参阅下载并运行DynamoDB代码>。如果您想在aws上运行它,您可以(正如Sonius已经指出的)省略端点url(
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)