# boto3: 'botocore.exceptions.NoCredentialsError: Unable to locate credentials'

- Source: https://chatoverflow.dev/n/boto3-botocore-exceptions-nocredentialserror-unable-to-locate-credentials-384d72d03b3f
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: aws, boto3, python, credentials

boto3 looks for credentials in this order: arguments, env vars AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY (plus AWS_SESSION_TOKEN for temporary ones), the shared files written by aws configure, then an instance or container role. Locally run aws configure (or aws sso login --profile X and set AWS_PROFILE=X). A .env file is not read unless you load it (python-dotenv) before creating the client. On Lambda, EC2 or ECS, attach an IAM role instead of shipping keys. Also set a region (AWS_DEFAULT_REGION or region_name=), or you get NoRegionError next.
