{"record":{"id":"f4a0c0402fe0c2d7","repo":"pola-rs/polars","slug":"boto3-must-be-installed-to-use-credentialprovider","errorCode":null,"errorMessage":"boto3 must be installed to use `CredentialProviderAWS`","messagePattern":"boto3 must be installed to use `CredentialProviderAWS`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/cloud/credential_provider/_providers.py","lineNumber":310,"sourceCode":"\n            return False\n\n        return True\n\n    def _session(self) -> boto3.Session:\n        # Note: boto3 automatically sources the AWS_PROFILE env var\n        import boto3\n\n        return boto3.Session(\n            profile_name=self.profile_name,\n            region_name=self.region_name,\n        )\n\n    @classmethod\n    def _ensure_module_availability(cls) -> None:\n        if importlib.util.find_spec(\"boto3\") is None:\n            msg = \"boto3 must be installed to use `CredentialProviderAWS`\"\n            raise ImportError(msg)\n\n    class EmptyCredentialError(Exception):\n        \"\"\"\n        Raised when boto3 returns empty credentials.\n\n        This generally indicates that no credentials could be found in the\n        environment.\n        \"\"\"\n\n\nclass CredentialProviderAzure(CachingCredentialProvider):\n    \"\"\"\n    Azure Credential Provider.\n\n    Using this requires the `azure-identity` Python package to be installed.\n\n    .. warning::\n        This functionality is considered **unstable**. It may be changed","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/cloud/credential_provider/_providers.py#L292-L328","documentation":"CredentialProviderAWS requires boto3 to fetch AWS credentials. At construction, _ensure_module_availability checks for the boto3 module and raises ImportError immediately if it is absent, so users get a clear message instead of a failure deep inside credential retrieval.","triggerScenarios":"Instantiating CredentialProviderAWS directly or via credential_provider='aws' when boto3 is not installed in the environment.","commonSituations":"Fresh venv/CI image without boto3; polars installed bare (no cloud extras); code moved from a machine with AWS tooling to one without.","solutions":["pip install boto3.","Install the bundle: pip install 'polars[aws]' (or fsspec/s3fs equivalents).","Use a different credential mechanism (explicit keys in storage_options, or CredentialProviderAWS replaced by env vars AWS_ACCESS_KEY_ID etc.)."],"exampleFix":"// before\n provider = pl.CredentialProviderAWS()\n// after\n # pip install boto3\n provider = pl.CredentialProviderAWS()","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec('boto3') is None:\n    raise RuntimeError('install boto3 before using CredentialProviderAWS')","typeGuard":"def can_use_aws_provider() -> bool:\n    return importlib.util.find_spec('boto3') is not None","tryCatchPattern":"try:\n    provider = pl.CredentialProviderAWS()\nexcept ImportError as e:\n    if 'boto3 must be installed' in str(e):\n        provider = None  # rely on AWS_ACCESS_KEY_ID env vars\n    else:\n        raise","preventionTips":["Include boto3 (or 'polars[aws]') in base image requirements.","Check dependency availability at application boot for all configured providers.","Document required extras next to the credential_provider option in internal config docs."],"tags":["python","aws","boto3","missing-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}