mem0ai/mem0 · error · ImportError

The 'upstash_vector' library is required. Please install it

Error message

The 'upstash_vector' library is required. Please install it using 'pip install upstash_vector'.

What it means

Raised at import time when the `upstash_vector` package is missing. mem0's Upstash Vector store wraps that SDK's Index client, and like all provider SDKs it is optional, so the module raises ImportError with the exact pip command rather than failing later at runtime.

Source

Thrown at mem0/vector_stores/upstash_vector.py:12

import logging
import re
from typing import Any, Dict, List, Optional

from pydantic import BaseModel

from mem0.vector_stores.base import VectorStoreBase

try:
    from upstash_vector import Index
except ImportError:
    raise ImportError("The 'upstash_vector' library is required. Please install it using 'pip install upstash_vector'.")


logger = logging.getLogger(__name__)

_SAFE_FILTER_KEY = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*\Z")


def _validate_filter(key: str, value: Any) -> None:
    if not isinstance(key, str) or not _SAFE_FILTER_KEY.fullmatch(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, "
            f"got {type(value).__name__}"
        )
    if isinstance(value, str) and ('"' in value or "\\" in value):
        raise ValueError(
            f"Filter value for {key!r} contains prohibited characters "

View on GitHub (pinned to 001c235229)

Solutions

  1. Install with the exact name shown: `pip install upstash_vector`.
  2. Ensure UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN (or explicit url/token config) are also available, since the next failure after import is missing credentials.
  3. Verify the interpreter/environment if the import still fails post-install.

Example fix

# before
from mem0.vector_stores.upstash_vector import UpstashVector  # ImportError

# after
# pip install upstash_vector
from mem0.vector_stores.upstash_vector import UpstashVector  # ok
Defensive patterns

Strategy: try-catch

Validate before calling

import importlib.util

if importlib.util.find_spec("upstash_vector") is None:
    raise SystemExit("Missing dependency: upstash_vector. Run: pip install upstash_vector")

Try / catch

try:
    from mem0.vector_stores.upstash_vector import UpstashVector
except ImportError as e:
    raise RuntimeError(f"Upstash Vector SDK missing: {e}. Install with pip install upstash_vector.") from e

Prevention

When it happens

Trigger: `from mem0.vector_stores.upstash_vector import UpstashVector` or `"vector_store": {"provider": "upstash_vector"}` where `from upstash_vector import Index` fails.

Common situations: Package name confusion — the correct PyPI name uses an underscore (`upstash_vector`), while Upstash docs sometimes show `@upstash/vector` for JS; base mem0ai installs; serverless deployments that prune dependencies aggressively.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/9124f142d83be042. Report an issue: GitHub.