Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'S3' object has no attribute 'Bucket' #1235

Closed
arijitArusan opened this issue Aug 19, 2017 · 3 comments
Closed

AttributeError: 'S3' object has no attribute 'Bucket' #1235

arijitArusan opened this issue Aug 19, 2017 · 3 comments
Assignees
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. question

Comments

@arijitArusan
Copy link

arijitArusan commented Aug 19, 2017

i am new to aws, when ever i am trying to download a file it is giving this error
I am using boto3
AttributeError: 'S3' object has no attribute 'Bucket'

below is my code snippet

try:
    s3.Bucket(bucketname).download_file(key,directory)
except botocore.exceptions.ClientError as e:
    if e.response['Error']['Code'] == "404":
        print("The object does not exist.")
@chenhe95
Copy link

How are you creating the s3 object?
Because s3 = boto3.client('s3') does not have Bucket and s3 = boto3.resource('s3') does have bucket.

@kyleknap kyleknap removed their assignment Aug 21, 2017
@kyleknap
Copy link
Member

I agree with @chenhe95 's suspicion. If you use the client interface to access the bucket:

boto3.client('s3').Bucket('mybucket')

you will get that error. Instead you need to be doing something like this:

boto3.resource('s3').Bucket('mybucket')

Let us know if that helps.

@kyleknap kyleknap added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Aug 21, 2017
@kyleknap kyleknap self-assigned this Aug 21, 2017
@JordonPhillips
Copy link
Contributor

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. question
Projects
None yet
Development

No branches or pull requests

4 participants