boto3例外nocredentialserror
一切作品除了步骤7中的代码外,也就是说:
import boto3
s3 = boto3.client('s3')
print("printing boto version: " + boto3.__version__)
def getObject(bucket, key):
objectBody = s3.get_object(Bucket = bucket, Key = key)
print(objectBody["Body"].read().decode("utf-8"))
print("\n")
print('Original object from the S3 bucket:')
# Replace the two input parameters of getObject() below with
# the S3 bucket name that you created in Step 1 and
# the name of the file that you uploaded to the S3 bucket in Step 2
getObject(<<My Bucket name>>,
"tutorial.txt")
print('Object transformed by S3 Object Lambda:')
# Replace the two input parameters of getObject() below with
# the ARN of your S3 Object Lambda access point that you saved earlier and
# the name of the file with the transformed data (which in this case is
# the same as the name of the file that you uploaded to the S3 bucket
# in Step 2)
getObject(<<MY_ARN>>,
"tutorial.txt")
我正确复制了Arn和Bucket名称,但是我仍然例外:
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/hooks.py", line 212, in _emit
response = handler(**kwargs)
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/signers.py", line 95, in handler
return self.sign(operation_name, request)
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/signers.py", line 167, in sign
auth.add_auth(request)
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/auth.py", line 401, in add_auth
raise NoCredentialsError()
botocore.exceptions.NoCredentialsError: Unable to locate credentials
我缺少什么?
I am trying to test sample AWS lamda code through this tutorial https://docs.aws.amazon.com/AmazonS3/latest/userguide/tutorial-s3-object-lambda-uppercase.html#ol-upper-step6
Everything works except the code in Step 7, that is:
import boto3
s3 = boto3.client('s3')
print("printing boto version: " + boto3.__version__)
def getObject(bucket, key):
objectBody = s3.get_object(Bucket = bucket, Key = key)
print(objectBody["Body"].read().decode("utf-8"))
print("\n")
print('Original object from the S3 bucket:')
# Replace the two input parameters of getObject() below with
# the S3 bucket name that you created in Step 1 and
# the name of the file that you uploaded to the S3 bucket in Step 2
getObject(<<My Bucket name>>,
"tutorial.txt")
print('Object transformed by S3 Object Lambda:')
# Replace the two input parameters of getObject() below with
# the ARN of your S3 Object Lambda access point that you saved earlier and
# the name of the file with the transformed data (which in this case is
# the same as the name of the file that you uploaded to the S3 bucket
# in Step 2)
getObject(<<MY_ARN>>,
"tutorial.txt")
I have correctly copied ARN and bucket name, but still I get exception:
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/hooks.py", line 212, in _emit
response = handler(**kwargs)
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/signers.py", line 95, in handler
return self.sign(operation_name, request)
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/signers.py", line 167, in sign
auth.add_auth(request)
File "/Users/deepaksharma/object-lamba/env/lib/python3.8/site-packages/botocore/auth.py", line 401, in add_auth
raise NoCredentialsError()
botocore.exceptions.NoCredentialsError: Unable to locate credentials
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要与AWS帐户建立会话。
在Python中建立会话:
或者,配置您的CLI:
You need to establish a session with your AWS account.
Establish a session in Python:
Or, configure your CLI: