mem0ai/mem0 · error · ImportError
The 'langchain_community' library is required. Please instal
Error message
The 'langchain_community' library is required. Please install it using 'pip install langchain_community'.
What it means
Module-level ImportError raised when mem0.vector_stores.langchain is imported but langchain_community is not installed. The module hard-depends on langchain_community.vectorstores.VectorStore at import time, so merely importing the module without the package fails.
Source
Thrown at mem0/vector_stores/langchain.py:9
import logging
from typing import Dict, List, Optional
from pydantic import BaseModel
try:
from langchain_community.vectorstores import VectorStore
except ImportError:
raise ImportError(
"The 'langchain_community' library is required. Please install it using 'pip install langchain_community'."
)
from mem0.vector_stores.base import VectorStoreBase
logger = logging.getLogger(__name__)
class OutputData(BaseModel):
id: Optional[str] # memory id
score: Optional[float] # distance
payload: Optional[Dict] # metadata
# Methods that accept a pre-computed embedding and return (Document, float) pairs.
# Tried in order; first match wins. Not part of the base VectorStore contract,
# but exposed by several concrete implementations.
_SCORED_BY_VECTOR_METHODS = [View on GitHub (pinned to 001c235229)
Solutions
- pip install langchain_community (or add it to requirements.txt / the Docker image)
- Use a dedicated extra if provided (e.g. mem0ai[lc] style extras) so the dependency is declared
- If langchain was unintended, switch the provider back to faiss/qdrant/chroma etc.
Example fix
# before # provider='langchain' without the package -> ImportError at import time # after # shell: pip install langchain_community from mem0.vector_stores.langchain import LCVectorStore
Defensive patterns
Strategy: fallback
Validate before calling
try:
import langchain_community # noqa
HAVE_LC = True
except ImportError:
HAVE_LC = False
provider = 'langchain' if HAVE_LC else 'faiss' Try / catch
try:
from mem0.vector_stores.langchain import LCVectorStore
except ImportError as e:
raise RuntimeError('Run: pip install langchain_community') from e Prevention
- Declare langchain_community in requirements when using the langchain provider
- Smoke-test provider imports in CI for every configured vector store
When it happens
Trigger: Selecting vector_store provider 'langchain' in MemoryConfig, or importing mem0.vector_stores.langchain, in an environment where pip install langchain_community was never run.
Common situations: Fresh installs using only 'pip install mem0ai' (langchain is an optional extra); deploying to slim Docker images; adding the langchain provider to an existing app without updating requirements.
Related errors
- The 'upstash_vector' library is required. Please install it
- langchain is not installed. Please install it using `pip ins
- 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
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/7d680a209564cb55.
Report an issue: GitHub.