title: Download file from AWS S3 using Python
body: <p>I am trying to download a file from Amazon S3 bucket to my local using the below code but I get an error saying &quot;Unable to locate credentials&quot;</p>
  <p>Given below is the code I have written:</p>
  <pre><code>from boto3.session import Session
  import boto3
  
  ACCESS_KEY = 'ABC'
  SECRET_KEY = 'XYZ'
  
  session = Session(aws_access_key_id=ACCESS_KEY,
                aws_secret_access_key=SECRET_KEY)
  s3 = session.resource('s3')
  your_bucket = s3.Bucket('bucket_name')
  
  for s3_file in your_bucket.objects.all():
      print(s3_file.key) # prints the contents of bucket
  
  s3 = boto3.client ('s3')
  
  s3.download_file('your_bucket','k.png','/Users/username/Desktop/k.png')
  </code></pre>
  <p>Could anyone help me on this?</p>