mem0ai/mem0 · error · ImportError

The 'boto3' library is required. Please install it using 'pi

Error message

The 'boto3' library is required. Please install it using 'pip install boto3'.

What it means

mem0/embeddings/aws_bedrock.py wraps its boto3 import in try/except ImportError and re-raises with install instructions when boto3 is absent. This is a hard import-time failure: merely importing the module (e.g. via mem0's embeddings registry) fails without the AWS SDK. boto3 is an optional dependency, not installed with the core mem0ai package.

Source

Thrown at mem0/embeddings/aws_bedrock.py:8

import json
import os
from typing import Literal, Optional

try:
    import boto3
except ImportError:
    raise ImportError("The 'boto3' library is required. Please install it using 'pip install boto3'.")

import numpy as np

from mem0.configs.embeddings.base import BaseEmbedderConfig
from mem0.embeddings.base import EmbeddingBase


class AWSBedrockEmbedding(EmbeddingBase):
    """AWS Bedrock embedding implementation.

    This class uses AWS Bedrock's embedding models.
    """

    def __init__(self, config: Optional[BaseEmbedderConfig] = None):
        super().__init__(config)

        self.config.model = self.config.model or "amazon.titan-embed-text-v1"

View on GitHub (pinned to 001c235229)

Solutions

  1. pip install boto3 in the interpreter that runs the app
  2. Add boto3 to your dependency manifest (requirements.txt / pyproject) so deploys install it
  3. For Docker, ensure the RUN pip install step includes boto3 in the final image stage

Example fix

# before: ImportError raised at import

# after
# shell:
pip install boto3
Defensive patterns

Strategy: validation

Validate before calling

try:
    import boto3  # noqa: F401
except ImportError:
    raise RuntimeError("aws_bedrock embedder requires: pip install boto3")

Prevention

When it happens

Trigger: Configuring embedder={'provider': 'aws_bedrock'} without pip install boto3; running in a slim Docker image without the AWS SDK; a different virtualenv being active at runtime than at install time.

Common situations: CI pipelines installing only requirements.txt that lacks boto3; conda vs pip environment mismatch; local boto3 present but production image missing it.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/a22b9a945221e554. Report an issue: GitHub.