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

mem0/embeddings and vector-store configs import optional dependencies inside try/except ImportError blocks. If the upstash-vector package is not installed, importing UpstashVectorConfig's module re-raises ImportError with install instructions. Note the package is installed as 'upstash-vector' (pip) but imported as 'upstash_vector' (module), and the message reflects the module name.

Source

Thrown at mem0/configs/vector_stores/upstash_vector.py:9

import os
from typing import Any, ClassVar, Dict, Optional

from pydantic import BaseModel, ConfigDict, Field, model_validator

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


class UpstashVectorConfig(BaseModel):
    Index: ClassVar[type] = Index

    url: Optional[str] = Field(None, description="URL for Upstash Vector index")
    token: Optional[str] = Field(None, description="Token for Upstash Vector index")
    client: Optional[Index] = Field(None, description="Existing `upstash_vector.Index` client instance")
    collection_name: str = Field("mem0", description="Namespace to use for the index")
    enable_embeddings: bool = Field(
        False, description="Whether to use built-in upstash embeddings or not. Default is True."
    )

    @model_validator(mode="before")
    @classmethod
    def check_credentials_or_client(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        client = values.get("client")
        url = values.get("url") or os.environ.get("UPSTASH_VECTOR_REST_URL")

View on GitHub (pinned to 001c235229)

Solutions

  1. pip install upstash-vector (the PyPI name uses a hyphen)
  2. Confirm it landed in the interpreter running the app: <python-used> -m pip install upstash-vector
  3. Add upstash-vector to requirements.txt/pyproject dependencies for reproducible environments

Example fix

# before: ImportError at import time

# after
# shell:
pip install upstash-vector
Defensive patterns

Strategy: validation

Validate before calling

try:
    import upstash_vector  # noqa: F401
    HAS_UPSTASH = True
except ImportError:
    HAS_UPSTASH = False

if provider == "upstash_vector" and not HAS_UPSTASH:
    raise RuntimeError("run: pip install upstash-vector")

Try / catch

try:
    from mem0.vector_stores.upstash_vector import UpstashVector
except ImportError as e:
    if "upstash_vector" in str(e):
        subprocess check or fail fast with install instructions
    raise

Prevention

When it happens

Trigger: Selecting vector_store={'provider': 'upstash_vector', ...} without having installed the extra; installing into a different virtualenv/Python than the one running the app; a requirements file that lists upstash but not upstash-vector.

Common situations: pip install mem0ai pulls only core deps; provider extras must be installed manually; using poetry/pdm/uv where the dependency was added to a different group; Docker image built without the extra.

Related errors


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