mem0ai/mem0 · error · ImportError
The 'pymilvus' library is required. Please install it using
Error message
The 'pymilvus' library is required. Please install it using 'pip install pymilvus'.
What it means
Module-level ImportError raised when pymilvus is missing. The Milvus vector store imports pymilvus symbols (MilvusClient, CollectionSchema, ...) at module import, so configuring provider 'milvus' in an environment without pymilvus fails immediately.
Source
Thrown at mem0/vector_stores/milvus.py:13
import logging
import re
from typing import Dict, Optional
from pydantic import BaseModel
from mem0.configs.vector_stores.milvus import MetricType
from mem0.vector_stores.base import VectorStoreBase
try:
import pymilvus # noqa: F401
except ImportError:
raise ImportError("The 'pymilvus' library is required. Please install it using 'pip install pymilvus'.")
from pymilvus import (
CollectionSchema,
DataType,
FieldSchema,
Function,
FunctionType,
MilvusClient,
)
logger = logging.getLogger(__name__)
class OutputData(BaseModel):
id: Optional[str] # memory id
score: Optional[float] # distance
payload: Optional[Dict] # metadata
View on GitHub (pinned to 001c235229)
Solutions
- pip install pymilvus
- Add pymilvus to the deployment image's dependency list
- Verify with 'python -c "import pymilvus"' before switching the provider
Example fix
# before # MemoryConfig vector_store.provider='milvus' -> ImportError # after # shell: pip install pymilvus from mem0.vector_stores.milvus import Milvus
Defensive patterns
Strategy: fallback
Validate before calling
try:
import pymilvus # noqa
HAVE_MILVUS = True
except ImportError:
HAVE_MILVUS = False Try / catch
try:
from mem0.vector_stores.milvus import Milvus
except ImportError as e:
raise RuntimeError('Run: pip install pymilvus') from e Prevention
- Install pymilvus in every image/environment that configures provider='milvus'
- Verify with python -c 'import pymilvus' during deploy preflight
When it happens
Trigger: Setting provider='milvus' in vector_store config, or importing mem0.vector_stores.milvus, without pymilvus installed.
Common situations: Base mem0ai install without extras; CI images trimmed of optional deps; local dev against Qdrant/FAISS then deploying the same image pointed at Milvus.
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/760a9b2c877f62b5.
Report an issue: GitHub.