{"record":{"id":"7f12581e0347c72f","repo":"run-llama/llama_index","slug":"please-run-pip-install-boto3-botocore-to-use-aws","errorCode":null,"errorMessage":"Please run `pip install boto3 botocore` to use AWS services.","messagePattern":"Please run `pip install boto3 botocore` to use AWS services\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/utilities/aws_utils.py","lineNumber":21,"sourceCode":"if TYPE_CHECKING:\n    import botocore\n\n\ndef get_aws_service_client(\n    service_name: Optional[str] = None,\n    region_name: Optional[str] = None,\n    aws_access_key_id: Optional[str] = None,\n    aws_secret_access_key: Optional[str] = None,\n    aws_session_token: Optional[str] = None,\n    profile_name: Optional[str] = None,\n    max_retries: Optional[int] = 3,\n    timeout: Optional[float] = 60.0,\n) -> \"botocore.client.BaseClient\":\n    try:\n        import boto3\n        import botocore\n    except ImportError:\n        raise ImportError(\n            \"Please run `pip install boto3 botocore` to use AWS services.\"\n        )\n\n    config = botocore.config.Config(\n        retries={\"max_attempts\": max_retries or 0, \"mode\": \"standard\"},\n        connect_timeout=timeout,\n    )\n\n    try:\n        if not profile_name and aws_access_key_id:\n            session = boto3.Session(\n                aws_access_key_id=aws_access_key_id,\n                aws_secret_access_key=aws_secret_access_key,\n                aws_session_token=aws_session_token,\n                region_name=region_name,\n            )\n            client = session.client(service_name, config=config)  # type: ignore\n        else:","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/utilities/aws_utils.py#L3-L39","documentation":"llama_index.core.utilities.aws_utils.get_aws_client() imports boto3/botocore lazily because they are optional dependencies of llama-index-core. If neither is installed, the ImportError tells you to install them explicitly before any AWS client (Bedrock, S3, etc.) can be created.","triggerScenarios":"Calling get_aws_client(service_name='bedrock-runtime', ...) (directly or via a Bedrock LLM/embedding integration or an S3 document reader) in an environment where 'pip install boto3 botocore' was never run.","commonSituations":"Fresh virtualenv with only llama-index-core installed; Docker images trimmed of optional deps; CI environments where the AWS extras were not declared in requirements.txt.","solutions":["Install the packages: pip install boto3 botocore.","Prefer the packaged integration extra, e.g. pip install llama-index-llms-bedrock, which pulls boto3 in.","Pin boto3 to a version compatible with your botocore to avoid downstream resolution errors."],"exampleFix":"# before (ImportError at runtime)\n client = get_aws_client(service_name='bedrock-runtime', region_name='us-east-1')\n\n# after (shell)\n# pip install boto3 botocore\n client = get_aws_client(service_name='bedrock-runtime', region_name='us-east-1')","handlingStrategy":"validation","validationCode":"def ensure_boto3_installed():\n    try:\n        import boto3, botocore  # noqa: F401\n    except ImportError:\n        raise RuntimeError('AWS features need boto3: pip install boto3 botocore')\n\nensure_boto3_installed()  # run at app startup, before any AWS call","typeGuard":"def aws_deps_available() -> bool:\n    try:\n        import boto3, botocore  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    client = get_aws_client('bedrock-runtime', region_name=region)\nexcept ImportError as e:\n    if 'boto3' in str(e):\n        raise RuntimeError('Install AWS deps: pip install llama-index-llms-bedrock') from e\n    raise","preventionTips":["Declare boto3 in requirements when using any AWS-backed integration.","Prefer integration extras (e.g. llama-index-llms-bedrock) that pull boto3 automatically.","Fail fast at startup with an import probe instead of mid-request."],"tags":["aws","boto3","import-error","dependencies"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}