question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Boto does not recognize ~.aws/credentials

See original GitHub issue

Following the Quickstart in the docs and am unable to authenticate using my ~/.aws/credentials files (aws cli commands work OK):

>>> import boto3
>>> 
>>> for bucket in boto3.resource('s3').buckets.all():
...     print(bucket.name)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/boto3/resources/collection.py", line 83, in __iter__
    for page in self.pages():
  File "/Library/Python/2.7/site-packages/boto3/resources/collection.py", line 161, in pages
    pages = [getattr(client, self._py_operation_name)(**params)]
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 310, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 396, in _make_api_call
    operation_model, request_dict)
  File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 111, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 136, in _send_request
    request = self.create_request(request_dict, operation_model)
  File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 120, in create_request
    operation_name=operation_model.name)
  File "/Library/Python/2.7/site-packages/botocore/hooks.py", line 226, in emit
    return self._emit(event_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/hooks.py", line 209, in _emit
    response = handler(**kwargs)
  File "/Library/Python/2.7/site-packages/botocore/signers.py", line 84, in handler
    return self.sign(operation_name, request)
  File "/Library/Python/2.7/site-packages/botocore/signers.py", line 119, in sign
    signer.add_auth(request=request)
  File "/Library/Python/2.7/site-packages/botocore/auth.py", line 621, in add_auth
    raise NoCredentialsError
botocore.exceptions.NoCredentialsError: Unable to locate credentials

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kadrachcommented, Oct 11, 2016

I have a similar issue too. The default “profile” for boto to use is an IAM profile.

Now I need to add an additional (non-default) profile. However boto3/botocore only pickup the ~.aws/credentials if both a default and other_profile are defined.

How do I not specify a default profile, and have an IAM profile be default, while also specifying other other_profile... in the credentials file?

2reactions
prayagupacommented, Jun 21, 2017

weird in my case,

Had

boto3.setup_default_session(profile_name="aws-federated")                                        
boto3.setup_default_session(region_name='us-west-2')  

had to remove region part and it works

boto3.setup_default_session(profile_name="aws-federated")                                        
##boto3.setup_default_session(region_name='us-west-2')  
Read more comments on GitHub >

github_iconTop Results From Across the Web

Credentials — Boto3 Docs 1.26.33 documentation - AWS
Configuring credentials¶. There are two types of configuration data in Boto3: credentials and non-credentials. Credentials include items such as ...
Read more >
Cannot read a key from S3 with boto, but can with aws cli
Succeeds with the cli, but not with boto. I've looked at the boto source to see if it's doing anything that requires extra...
Read more >
Introduction to Boto3 And AWS Credentials Setup ... - CloudThat
Boto is a software development kit of the Python SDK for AWS. ... To check if credentials are configured or not, go to...
Read more >
AWS Boto3 and AWS Credentials Configuration Settings for ...
I will show you in this lesson how to install boto3 python in the computer and get started with boto3 aws python tutorial....
Read more >
Resolving the Boto3 NoCredentialsError in Python - Rollbar
aws/credentials. Begin by navigating to this location and confirming the file exists. When opening the file in a text editor, you should see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found