{"record":{"id":"905a773d4ee5dbcd","repo":"mem0ai/mem0","slug":"the-boto3-library-is-required-please-install-it-905a77","errorCode":null,"errorMessage":"The 'boto3' library is required. Please install it using 'pip install boto3'.","messagePattern":"The 'boto3' library is required\\. Please install it using 'pip install boto3'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/llms/aws_bedrock.py","lineNumber":10,"sourceCode":"import json\nimport logging\nimport re\nfrom typing import Any, Dict, List, Optional, Union\n\ntry:\n    import boto3\n    from botocore.exceptions import ClientError, NoCredentialsError\nexcept ImportError:\n    raise ImportError(\"The 'boto3' library is required. Please install it using 'pip install boto3'.\")\n\nfrom mem0.configs.llms.aws_bedrock import AWSBedrockConfig\nfrom mem0.configs.llms.base import BaseLlmConfig\nfrom mem0.llms.base import LLMBase\nfrom mem0.memory.utils import extract_json\n\nlogger = logging.getLogger(__name__)\n\nPROVIDERS = [\n    \"ai21\", \"amazon\", \"anthropic\", \"cohere\", \"meta\", \"mistral\", \"stability\", \"writer\",\n    \"deepseek\", \"gpt-oss\", \"perplexity\", \"snowflake\", \"titan\", \"command\", \"j2\", \"llama\",\n    \"minimax\",\n]\n\n\ndef extract_provider(model: str, explicit_provider: Optional[str] = None) -> str:\n    \"\"\"Extract provider from model identifier, or return explicit_provider when set.\"\"\"\n    if explicit_provider:","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/llms/aws_bedrock.py#L1-L28","documentation":"Module-level ImportError raised when mem0/llms/aws_bedrock.py is imported without boto3/botocore installed. It fires when the AWSBedrockLLM class is loaded (llm provider 'aws_bedrock'), before any AWS call is attempted.","triggerScenarios":"Configuring llm.provider: aws_bedrock without pip install boto3; running mem0 in an environment where boto3 was never declared (it is an optional extra); Lambda/container images stripped of boto3 layers.","commonSituations":"Self-hosted mem0 pointing at Bedrock in a fresh venv; CI jobs missing boto3 in requirements.txt; assuming AWS SDK presence because the workload runs on EC2/ECS (it is not bundled by default in containers).","solutions":["pip install boto3","Add boto3 to the project's dependency list and redeploy","Verify in the runtime environment: python -c \"import boto3; print(boto3.__version__)\"","If running on AWS, prefer attaching an IAM role and still installing boto3 — the role solves credentials, not the missing library"],"exampleFix":"// before\nMemory.from_config({\"llm\": {\"provider\": \"aws_bedrock\", \"config\": {\"model\": \"anthropic.claude-3-5-sonnet-20240620-v1:0\"}}})  # ImportError\n\n# after\n# pip install boto3\nMemory.from_config({\"llm\": {\"provider\": \"aws_bedrock\", \"config\": {\"model\": \"anthropic.claude-3-5-sonnet-20240620-v1:0\", \"aws_region\": \"us-east-1\"}}})","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"boto3\") is None:\n    raise SystemExit(\"Missing dependency: pip install boto3\")","typeGuard":null,"tryCatchPattern":"try:\n    from mem0.llms.aws_bedrock import AWSBedrockLLM\nexcept ImportError as e:\n    raise SystemExit(f\"{e}; install with: pip install boto3\") from e","preventionTips":["Add boto3 to the deploy image whenever Bedrock is the LLM provider","Test imports in the actual runtime image, not the dev machine","Pin boto3 to a tested major version"],"tags":["python","aws","bedrock","boto3","import-error","dependencies","mem0"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}