{"id":9,"library":"boto3","title":"AWS SDK for Python (boto3)","description":"Official AWS SDK for Python. Extremely stable API — no breaking changes since v1.0. Two client styles: low-level client (boto3.client()) and high-level resource (boto3.resource()). Credential resolution follows a fixed chain. Region must be specified or set in environment — no global default. Released daily with new AWS service additions.","status":"active","version":"1.42.59","language":"python","source_language":"en","source_url":"https://github.com/boto/boto3","tags":["aws","cloud","s3","boto3","python","sdk","infrastructure"],"install":[{"cmd":"pip install boto3","lang":"bash","label":"Python"},{"cmd":"pip install boto3[crt]","lang":"bash","label":"With CRT (faster S3 transfers)"}],"dependencies":[{"reason":"Core HTTP client, credential management, and service definitions. Installed automatically. boto3 and botocore versions must stay in sync — pinning one without the other causes ImportError.","package":"botocore","optional":false},{"reason":"Multipart S3 transfers. Installed automatically.","package":"s3transfer","optional":false}],"imports":[{"note":"Omitting region_name raises NoRegionError for most services unless AWS_DEFAULT_REGION is set.","wrong":"import boto3\nclient = boto3.client('s3')","symbol":"boto3.client (low-level)","correct":"import boto3\n\n# Explicit credentials (not recommended for production)\nclient = boto3.client(\n    's3',\n    region_name='us-east-1',\n    aws_access_key_id='KEY',\n    aws_secret_access_key='SECRET'\n)\n\n# Preferred: let credential chain resolve\nclient = boto3.client('s3', region_name='us-east-1')"},{"note":"setup_default_session() modifies global state — unsafe in multi-threaded apps. Use Session() instead.","wrong":"boto3.setup_default_session(profile_name='my-profile')","symbol":"boto3.Session (multi-profile)","correct":"import boto3\n\nsession = boto3.Session(\n    profile_name='my-profile',\n    region_name='eu-west-1'\n)\nclient = session.client('dynamodb')"}],"quickstart":{"code":"import boto3\nfrom botocore.exceptions import ClientError, NoCredentialsError\n\n# Credential chain: env vars → ~/.aws/credentials → IAM role → ...\n# Set AWS_DEFAULT_REGION or pass region_name explicitly\nclient = boto3.client('s3', region_name='us-east-1')\n\ntry:\n    # List buckets\n    response = client.list_buckets()\n    for bucket in response['Buckets']:\n        print(bucket['Name'])\nexcept NoCredentialsError:\n    print('No AWS credentials found')\nexcept ClientError as e:\n    print(f\"Error: {e.response['Error']['Code']}: {e.response['Error']['Message']}\")","lang":"python","description":"Credential chain order: (1) explicit in code, (2) env vars AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, (3) ~/.aws/credentials, (4) ~/.aws/config, (5) EC2/ECS instance metadata."},"warnings":[{"fix":"Always pass region_name= explicitly, or set AWS_DEFAULT_REGION in the environment.","message":"Region is not globally defaulted. Calling boto3.client('s3') without region_name and without AWS_DEFAULT_REGION raises botocore.exceptions.NoRegionError. This is the most common source of 'it works on my machine' failures when deploying to CI/CD.","severity":"gotcha","affected_versions":"all"},{"fix":"Check all chain links: env vars (both KEY and SECRET required), ~/.aws/credentials format, IAM instance role attachment.","message":"NoCredentialsError means the credential chain was exhausted — no credentials found anywhere. Common in CI/CD when AWS_ACCESS_KEY_ID is set but AWS_SECRET_ACCESS_KEY is missing, or when ~/.aws/credentials exists locally but not in the deployment environment.","severity":"gotcha","affected_versions":"all"},{"fix":"Choose one pattern per codebase. boto3.resource() is higher-level but covers fewer services. boto3.client() covers all services.","message":"boto3.client() and boto3.resource() return different objects with different APIs. S3 client uses client.put_object(), resource uses s3.Object().put(). Mixing client and resource patterns causes AttributeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Pin both: boto3==X.Y.Z botocore==A.B.C. Check boto3's setup.py for the exact botocore version it requires.","message":"Pinning boto3 without pinning botocore (or vice versa) causes version conflicts. boto3 and botocore ship together daily and must stay version-compatible.","severity":"gotcha","affected_versions":"all"},{"fix":"except ClientError as e: if e.response['Error']['Code'] == 'NoSuchBucket': ...","message":"ClientError contains all AWS service errors. The error code is at e.response['Error']['Code'], not as a Python exception type. Catching specific AWS errors requires checking this string.","severity":"gotcha","affected_versions":"all"},{"fix":"Use boto3.Session() to create isolated sessions per thread/coroutine.","message":"boto3.setup_default_session() modifies global state and is not thread-safe. In multi-threaded or async applications, concurrent calls with different credentials will interfere.","severity":"gotcha","affected_versions":"all"}],"env_vars":{"optional":[{"name":"AWS_ACCESS_KEY_ID","note":"IAM access key. Part of credential chain — checked before ~/.aws/credentials."},{"name":"AWS_SECRET_ACCESS_KEY","note":"IAM secret key. Required alongside AWS_ACCESS_KEY_ID."},{"name":"AWS_DEFAULT_REGION","note":"Default region for all clients. Without this, region_name must be passed to every boto3.client() call or NoRegionError is raised."},{"name":"AWS_PROFILE","note":"Named profile from ~/.aws/credentials to use. Equivalent to Session(profile_name=...)."},{"name":"AWS_SESSION_TOKEN","note":"Required when using temporary credentials (STS AssumeRole, SSO, etc.)."}],"required":[]},"last_verified":"2026-05-11T18:11:07.370Z","next_check":"2026-06-01T00:00:00.000Z","problems":[{"fix":"Install boto3 using pip: `pip install boto3` (or `python -m pip install boto3` to ensure it's installed for the correct Python interpreter).","cause":"The boto3 library is not installed in the Python environment where the code is being executed, or the active Python interpreter does not have access to it.","error":"ModuleNotFoundError: No module named 'boto3'"},{"fix":"Configure your AWS credentials using the AWS CLI (`aws configure`), by setting `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables, or by ensuring the application runs on an EC2 instance with an appropriate IAM role.","cause":"boto3 cannot find the necessary AWS credentials to authenticate requests to AWS services. This occurs when credentials are not configured via environment variables, the AWS credentials file (~/.aws/credentials), or IAM roles.","error":"botocore.exceptions.NoCredentialsError: Unable to locate credentials"},{"fix":"Review the boto3 documentation for the specific service and operation to ensure all parameters are of the correct data type, format, and within valid ranges. Upgrade boto3 if using an older version that might not support newer parameters.","cause":"A parameter passed to a boto3 client method does not meet the expected type, format, or value required by the AWS service API.","error":"botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid type for parameter ..."},{"fix":"Instantiate an S3 resource object using `s3 = boto3.resource('s3')` to access high-level abstractions like `s3.Bucket('your-bucket-name').objects.all()`. If low-level API calls are needed, use `s3_client = boto3.client('s3')` and call methods like `s3_client.list_buckets()`.","cause":"This error typically occurs when attempting to use high-level resource-style methods (like `.Bucket()`) on a low-level client object (created with `boto3.client('s3')`) instead of a high-level resource object (created with `boto3.resource('s3')`).","error":"AttributeError: 'S3' object has no attribute 'Bucket'"},{"fix":"client = boto3.client('s3', region_name='us-east-1')\n# Or export AWS_REGION=us-east-1","cause":"Boto3 requires an AWS region to be specified but could not find one through environment variables, configuration files, or direct parameter.","error":"botocore.exceptions.NoRegionError: You must specify a region."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-11","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.26,"mem_mb":14.2,"disk_size":"50.3M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.3,"mem_mb":14.7,"disk_size":"61.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.94,"mem_mb":14.2,"disk_size":"51M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.03,"mem_mb":14.7,"disk_size":"63M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.55,"mem_mb":16.3,"disk_size":"53.2M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.69,"mem_mb":17.4,"disk_size":"64.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.26,"mem_mb":17,"disk_size":"54M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.51,"mem_mb":17.4,"disk_size":"66M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.42,"mem_mb":15.9,"disk_size":"44.8M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.49,"mem_mb":16.5,"disk_size":"56.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.31,"mem_mb":15.9,"disk_size":"45M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.46,"mem_mb":16.5,"disk_size":"57M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.52,"mem_mb":16.9,"disk_size":"44.5M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.47,"mem_mb":17.5,"disk_size":"55.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.35,"mem_mb":16.9,"disk_size":"45M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.5,"mem_mb":17.5,"disk_size":"57M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.96,"mem_mb":13.3,"disk_size":"49.8M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.01,"mem_mb":13.8,"disk_size":"61.2M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.76,"mem_mb":13.3,"disk_size":"50M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"crt","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.89,"mem_mb":13.9,"disk_size":"62M"}]},"quickstart_checks":{"last_tested":"2026-05-11","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}