mem0ai/mem0 · critical · ImportError
Apache Cassandra vector store requires cassandra-driver. Ple
Error message
Apache Cassandra vector store requires cassandra-driver. Please install it using 'pip install cassandra-driver'
What it means
Module-level ImportError raised when 'cassandra-driver' is not installed. CassandraDB imports cassandra.auth.PlainTextAuthProvider and cassandra.cluster.Cluster at the top of mem0/vector_stores/cassandra.py; failure aborts the import of the whole module, so the class cannot even be referenced.
Source
Thrown at mem0/vector_stores/cassandra.py:14
import json
import logging
import re
import uuid
from typing import Any, Dict, List, Optional
import numpy as np
from pydantic import BaseModel
try:
from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster
except ImportError:
raise ImportError(
"Apache Cassandra vector store requires cassandra-driver. "
"Please install it using 'pip install cassandra-driver'"
)
from mem0.vector_stores.base import VectorStoreBase
logger = logging.getLogger(__name__)
_SAFE_IDENTIFIER_RE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]{0,127}$')
def _validate_identifier(name: str, label: str = "identifier") -> str:
if not _SAFE_IDENTIFIER_RE.match(name):
raise ValueError(
f"Invalid {label} '{name}': only letters, digits, and underscores are allowed, "
"must start with a letter or underscore, and be at most 128 characters."
)
return nameView on GitHub (pinned to 001c235229)
Solutions
- Install the driver: pip install cassandra-driver.
- Remove the Cassandra import/config if the backend is not actually used.
- Guard provider selection so the module is only imported when the driver is present.
Example fix
# before from mem0.vector_stores.cassandra import CassandraDB # ImportError # after # pip install cassandra-driver from mem0.vector_stores.cassandra import CassandraDB
Defensive patterns
Strategy: validation
Validate before calling
try:
import cassandra # noqa: F401
CASSANDRA_OK = True
except ImportError:
CASSANDRA_OK = False
if provider == "cassandra" and not CASSANDRA_OK:
raise SystemExit("cassandra-driver missing: pip install cassandra-driver") Prevention
- Install cassandra-driver as an explicit extra whenever the cassandra provider is configured.
- Import provider modules lazily so one missing optional backend does not break unrelated code paths.
- Include driver presence in deployment health checks.
When it happens
Trigger: Any import of mem0.vector_stores.cassandra or VectorStoreConfig(provider='cassandra') without cassandra-driver installed. Fires at import time, before any connection to the cluster is attempted.
Common situations: Choosing the Cassandra backend without adding the driver to the environment; CI smoke tests that iterate over all vector store modules; slim Docker images built from mem0ai core without extras.
Related errors
- The 'upstash_vector' library is required. Please install it
- The 'pymochow' library is required. Please install it using
- The 'chromadb' library is required. Please install it using
- Elasticsearch requires extra dependencies. Install with `pip
- The 'langchain_community' library is required. Please instal
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/5fb6909812464e6e.
Report an issue: GitHub.