mem0ai/mem0 · error · ImportError
The 'azure-search-documents' library is required. Please ins
Error message
The 'azure-search-documents' library is required. Please install it using 'pip install azure-search-documents==11.5.2'.
What it means
Raised at module import of mem0.vector_stores.azure_ai_search when the azure.search.documents package (or its azure.identity/azure.core companions imported alongside) is not installed. The SDK is an optional dependency and mem0 pins the message to azure-search-documents==11.5.2 because newer 12.x versions changed the models API that this store imports (VectorizedQuery, compression types).
Source
Thrown at mem0/vector_stores/azure_ai_search.py:30
from azure.core.credentials import AzureKeyCredential
from azure.core.exceptions import ResourceNotFoundError
from azure.identity import DefaultAzureCredential
from azure.search.documents import SearchClient
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
BinaryQuantizationCompression,
HnswAlgorithmConfiguration,
ScalarQuantizationCompression,
SearchField,
SearchFieldDataType,
SearchIndex,
SimpleField,
VectorSearch,
VectorSearchProfile,
)
from azure.search.documents.models import VectorizedQuery
except ImportError:
raise ImportError(
"The 'azure-search-documents' library is required. Please install it using 'pip install azure-search-documents==11.5.2'."
)
logger = logging.getLogger(__name__)
class OutputData(BaseModel):
id: Optional[str]
score: Optional[float]
payload: Optional[dict]
class AzureAISearch(VectorStoreBase):
def __init__(
self,
service_name,
collection_name,
api_key,View on GitHub (pinned to 001c235229)
Solutions
- pip install azure-search-documents==11.5.2 (exact pin — the import block targets 11.x model paths)
- Also ensure azure-identity and azure-core are installed: pip install azure-identity
- Check the installed version: pip show azure-search-documents; downgrade if it is 12.x
- Pin the version in requirements.txt so future upgrades do not silently break the store
Example fix
# before: ImportError: The 'azure-search-documents' library is required ... from mem0 import Memory m = Memory.from_config(azure_search_cfg) # after # pip install azure-search-documents==11.5.2 azure-identity from mem0 import Memory m = Memory.from_config(azure_search_cfg)
Defensive patterns
Strategy: validation
Validate before calling
import importlib.metadata as md
try:
v = md.version('azure-search-documents')
except md.PackageNotFoundError:
v = None
if v is None or not v.startswith('11.'):
raise ConfigError('pip install azure-search-documents==11.5.2') Try / catch
try:
from mem0.vector_stores.azure_ai_search import AzureAISearch
except ImportError as e:
if 'azure-search-documents' in str(e):
raise ConfigError('install azure-search-documents==11.5.2') from e
raise Prevention
- Pin azure-search-documents==11.5.2 in requirements — 12.x moved the model imports mem0 uses
- Install azure-identity alongside it for DefaultAzureCredential flows
- Add a CI import test for each configured vector store provider
When it happens
Trigger: Configuring vector_store.provider='azure_ai_search' without the SDK installed; having azure-search-documents 12.x installed where VectorizedQuery/compression model imports moved, making the try-import fail even though a version is present; broken azure-identity install.
Common situations: pip install mem0ai alone then selecting Azure AI Search; a project that upgraded azure-search-documents to 12.x breaking the pinned imports; partially installed azure packages after a failed pip resolve.
Related errors
- Azure MySQL vector store requires PyMySQL and DBUtils. Pleas
- Insert failed for document ${result.key}: ${result.errorMess
- Delete failed for document ${vectorId}: ${result.errorMessag
- Update failed for document ${vectorId}: ${result.errorMessag
- Either 'password' must be provided or 'use_azure_credential'
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/90989a06dbb252e6.
Report an issue: GitHub.