{"id":1099,"hash":"e42fc059b289f5aa67b3b1dacbcdaefc62097ca6fc88306f6fa033138bc85350","pattern":"botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found","full_message":"I'm downloading files from AWS S3 Bucket like so:\n\nimport boto3\n\ns3client = boto3.client(\"s3\")\ns3 = boto3.resource('s3')\n\nbucket_name = 'practice_bucket'\nbucket = s3.Bucket(bucket_name)\n\nfor obj in bucket.objects.all():\n    filename = obj.key.rsplit('/')[-1]\n    s3client.download_file(bucket_name, obj.key, \"/txt/\" + filename)\n\nWhen attempting to place some files under a subdirectory, e.g. /txt/, I get the error:\n\nbotocore.exceptions.ClientError: An error occurred (404) when calling\nthe HeadObject operation: Not Found\n\nOddly, it works on other file types using the same method, but doesn’t work for ones with .json extension.\n\nWhat could be the issue? I even tried without placing them in an absolute subdirectory path, and I get no error and downloads the file onto the same directory as the script downloading. But when I actually define the path to download the file to, I get the error.","ecosystem":"pypi","package_name":"python-2.7","package_version":null,"solution":"Your code is correct.\n\nbotocore.exceptions.ClientError: An error occurred (404) when calling\nthe HeadObject operation: Not Found\n\nThis error is thrown when the object you are trying to fetch is not present in the bucket.","confidence":0.7000000000000001,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/44895334/botocore-exceptions-clienterror-an-error-occurred-404-when-calling-the-headob","votes":53,"created_at":"2026-04-19T04:52:20.953993+00:00","updated_at":"2026-04-19T04:52:20.953993+00:00"}