mem0ai/mem0 · critical · ImportError

The 'pymochow' library is required. Please install it using

Error message

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

What it means

BaiduDB raises this ImportError at module import time when the 'pymochow' SDK (Baidu VectorDB client) cannot be imported. The try/except around the pymochow imports re-raises immediately, so merely importing mem0.vector_stores.baidu fails; the Baidu vector store cannot be used at all without the SDK.

Source

Thrown at mem0/vector_stores/baidu.py:39

    )
    from pymochow.model.schema import (
        AutoBuildRowCountIncrement,
        Field,
        FilteringIndex,
        HNSWParams,
        Schema,
        VectorIndex,
    )
    from pymochow.model.table import (
        BM25SearchRequest,
        FloatVector,
        Partition,
        Row,
        VectorSearchConfig,
        VectorTopkSearchRequest,
    )
except ImportError:
    raise ImportError("The 'pymochow' library is required. Please install it using 'pip install pymochow'.")

logger = logging.getLogger(__name__)


class OutputData(BaseModel):
    id: Optional[str]  # memory id
    score: Optional[float]  # distance
    payload: Optional[Dict]  # metadata


class BaiduDB(VectorStoreBase):
    _SAFE_FILTER_KEY = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")

    def __init__(
        self,
        endpoint: str,
        account: str,
        api_key: str,

View on GitHub (pinned to 001c235229)

Solutions

  1. Install the SDK: pip install pymochow.
  2. If you did not intend to use Baidu, stop importing/instantiating BaiduDB (the error is import-time, so even an unused import triggers it).
  3. Pin a known-good pymochow version in requirements to avoid silent dependency drift.

Example fix

# before
from mem0.vector_stores.baidu import BaiduDB  # ImportError: pymochow required

# after
# pip install pymochow
from mem0.vector_stores.baidu import BaiduDB
Defensive patterns

Strategy: validation

Validate before calling

try:
    import pymochow  # noqa: F401
    BAIDU_OK = True
except ImportError:
    BAIDU_OK = False

if not BAIDU_OK:
    raise SystemExit("Baidu provider selected but pymochow is missing: pip install pymochow")

Prevention

When it happens

Trigger: Any 'from mem0.vector_stores.baidu import BaiduDB' or VectorStoreConfig(provider='baidu') in an environment lacking pymochow. The error fires on the import line itself, before any class is instantiated.

Common situations: Using the Baidu VectorDB backend without installing the vendor SDK; mem0ai's optional extras not included in the deployment image; a CI matrix that imports every vector store module to smoke-test it.

Related errors


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