mem0ai/mem0 · critical · ImportError
OpenSearch requires extra dependencies. Install with `pip in
Error message
OpenSearch requires extra dependencies. Install with `pip install opensearch-py`
What it means
Import-time ImportError from the OpenSearch vector store: the module needs the opensearch-py package (classes OpenSearch and RequestsHttpConnection). If it is absent, the guard fires as soon as the module is imported — i.e. as soon as the config selects the opensearch provider — before any connection attempt.
Source
Thrown at mem0/vector_stores/opensearch.py:9
import logging
import re
import time
from typing import Any, Dict, List, Optional
try:
from opensearchpy import OpenSearch, RequestsHttpConnection
except ImportError:
raise ImportError("OpenSearch requires extra dependencies. Install with `pip install opensearch-py`") from None
from pydantic import BaseModel
from mem0.configs.vector_stores.opensearch import OpenSearchConfig
from mem0.vector_stores.base import VectorStoreBase
logger = logging.getLogger(__name__)
_SAFE_FILTER_KEY = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_.]*$")
_IDENTITY_FILTER_KEYS = ("user_id", "agent_id", "run_id")
def _validate_filter(key: str, value) -> None:
if not isinstance(key, str) or not _SAFE_FILTER_KEY.match(key):
raise ValueError(f"Invalid filter key: {key!r}")
if not isinstance(value, (str, int, float, bool)):
raise ValueError(
f"Filter value for {key!r} must be str, int, float, or bool, "View on GitHub (pinned to 001c235229)
Solutions
- pip install opensearch-py
- If you installed elasticsearch by mistake, either add opensearch-py or switch provider to elasticsearch
- Pin opensearch-py in the deploy requirements so image builds include it
Example fix
# before pip install mem0ai # provider "opensearch" -> ImportError # after pip install mem0ai opensearch-py
Defensive patterns
Strategy: validation
Validate before calling
try:
import opensearchpy # noqa
except ImportError:
raise SystemExit("opensearch-py required: pip install opensearch-py") Prevention
- Install opensearch-py in the base image when the provider is opensearch
- CI smoke test: import the module for the configured provider
- Do not substitute elasticsearch-py; it is a different provider
When it happens
Trigger: Configuring vector_store.provider="opensearch" without pip install opensearch-py; environments where elasticsearch (different package) was installed instead; CI base images missing the vector-store extras.
Common situations: Installing mem0ai without extras then pointing config at OpenSearch; name confusion between opensearch-py and elasticsearch-py; slim Docker images that strip optional deps.
Related errors
- The 'upstash_vector' library is required. Please install it
- The 'pymochow' library is required. Please install it using
- Apache Cassandra vector store requires cassandra-driver. Ple
- The 'chromadb' library is required. Please install it using
- Elasticsearch requires extra dependencies. Install with `pip
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/050f9a224c53165d.
Report an issue: GitHub.