{"id":1095,"hash":"8c3c05f3db60120d3b314f9931375765b714edf09eb1523e7bf6b4cb2d00e45d","pattern":"Boto3 Error: botocore.exceptions.NoCredentialsError: Unable to locate credentials","full_message":"When I simply run the following code, I always gets this error.\n\ns3 = boto3.resource('s3')\nbucket_name = \"python-sdk-sample-%s\" % uuid.uuid4()\nprint(\"Creating new bucket with name:\", bucket_name)\ns3.create_bucket(Bucket=bucket_name)\n\nI have saved my credential file in\n\nC:\\Users\\myname\\.aws\\credentials, from where Boto should read my credentials.\n\nIs my setting wrong?\n\nHere is the output from boto3.set_stream_logger('botocore', level='DEBUG').\n\n2015-10-24 14:22:28,761 botocore.credentials [DEBUG] Skipping environment variable credential check because profile name was explicitly set.\n2015-10-24 14:22:28,761 botocore.credentials [DEBUG] Looking for credentials via: env\n2015-10-24 14:22:28,773 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file\n2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: config-file\n2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: ec2-credentials-file\n2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: boto-config\n2015-10-24 14:22:28,774 botocore.credentials [DEBUG] Looking for credentials via: iam-role","ecosystem":"pypi","package_name":"boto","package_version":null,"solution":"try specifying keys manually\n\n    s3 = boto3.resource('s3',\n         aws_access_key_id=ACCESS_ID,\n         aws_secret_access_key= ACCESS_KEY)\n\nMake sure you don't include your ACCESS_ID and ACCESS_KEY in the code directly for security concerns.\nConsider using environment configs and injecting them in the code as suggested by @Tiger_Mike.\n\nFor Prod environments consider using rotating access keys:\nhttps://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_RotateAccessKey","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/33297172/boto3-error-botocore-exceptions-nocredentialserror-unable-to-locate-credential","votes":249,"created_at":"2026-04-19T04:52:20.951248+00:00","updated_at":"2026-04-19T04:52:20.951248+00:00"}