{"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/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/io/cloud/credential_provider/_providers.py#L292-L328","documentation":"CredentialProviderAWS._ensure_module_availability (py-polars/src/polars/io/cloud/credential_provider/_providers.py:305-309) checks importlib.util.find_spec('boto3') and raises ImportError when the Python-side AWS credential provider is required but boto3 is absent. boto3 is optional: polars' native Rust cloud stack works without it, but aws_profile resolution and assume_role support route through Python/boto3.","triggerScenarios":"pl.scan_parquet('s3://...', storage_options={'aws_profile': 'x'}) or credential_provider=pl.CredentialProviderAWS(...) in an environment where boto3 is not installed.","commonSituations":"Minimal Docker/CI images; adding an aws_profile to storage_options in a project that previously relied on anonymous access or env-var credentials (which need no boto3).","solutions":["pip install boto3 in any environment that uses aws_profile or CredentialProviderAWS","Rely on the native credential path instead: standard AWS env vars (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY) or instance roles, with no aws_profile key","Keep static key-based storage_options without a profile, which dispatch to the Rust side directly"],"exampleFix":"# before - ImportError: boto3 must be installed\nlf = pl.scan_parquet(\"s3://bucket/f.parquet\", storage_options={\"aws_profile\": \"prod\"})\n# after\n# $ pip install boto3\nlf = pl.scan_parquet(\"s3://bucket/f.parquet\", storage_options={\"aws_profile\": \"prod\"})","handlingStrategy":"validation","validationCode":"import importlib.util\n\ndef require_boto3() -> None:\n    if importlib.util.find_spec(\"boto3\") is None:\n        raise ImportError(\"pip install boto3 to use aws_profile / CredentialProviderAWS\")","typeGuard":null,"tryCatchPattern":"try:\n    lf = pl.scan_parquet(url, storage_options=opts)\nexcept ImportError as e:\n    if \"boto3\" in str(e):\n        raise SystemExit(\"this job uses aws_profile: pip install boto3\") from e\n    raise","preventionTips":["Declare boto3 in environments where storage_options uses aws_profile or assume_role","Run a startup dependency check when cloud credentials are configured","Add a requirements extra (e.g. polars-aws) grouping polars + boto3 in your repo"],"tags":["polars","aws","boto3","credentials","importerror","dependencies"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}