OpenBMB/ChatDev · error · ImportError

mem0ai is required for Mem0Memory. Install it with: pip inst

Error message

mem0ai is required for Mem0Memory. Install it with: pip install mem0ai

What it means

Mem0Memory needs the third-party mem0ai package. _get_mem0_client lazily imports mem0.MemoryClient; if mem0ai is not installed the ImportError is re-raised with install instructions.

Source

Thrown at runtime/node/agent/memory/mem0_memory.py:26

from entity.configs import MemoryStoreConfig
from entity.configs.node.memory import Mem0MemoryConfig
from runtime.node.agent.memory.memory_base import (
    MemoryBase,
    MemoryContentSnapshot,
    MemoryItem,
    MemoryWritePayload,
)

logger = logging.getLogger(__name__)


def _get_mem0_client(config: Mem0MemoryConfig):
    """Lazy-import mem0ai and create a MemoryClient."""
    try:
        from mem0 import MemoryClient
    except ImportError:
        raise ImportError(
            "mem0ai is required for Mem0Memory. Install it with: pip install mem0ai"
        )

    client_kwargs: Dict[str, Any] = {}
    if config.api_key:
        client_kwargs["api_key"] = config.api_key
    if config.org_id:
        client_kwargs["org_id"] = config.org_id
    if config.project_id:
        client_kwargs["project_id"] = config.project_id

    return MemoryClient(**client_kwargs)


class Mem0Memory(MemoryBase):
    """Memory store backed by Mem0's managed cloud service.

    Mem0 handles embeddings, storage, and semantic search server-side.

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. pip install mem0ai
  2. Install the package's mem0 extras if provided
  3. Verify the deployment image includes optional memory dependencies

Example fix

# shell
pip install mem0ai
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec('mem0') is None:
    raise ConfigError('mem0ai not installed; run pip install mem0ai')

Prevention

When it happens

Trigger: Using the Mem0 memory backend (store type 'mem0') in an environment where `pip install mem0ai` was never run; Mem0Memory.__init__ calls _get_mem0_client immediately, so the error surfaces at agent construction.

Common situations: Missing extras (e.g. pip install 'package[mem0]'); deploying to a slim container without optional deps; wrong venv activated.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/6fa9edf8965c7b45. Report an issue: GitHub.