mem0ai/mem0 · error · ImportError
google-auth is required for GCP authentication. Install with
Error message
google-auth is required for GCP authentication. Install with: pip install google-auth
What it means
Raised at import time of mem0.utils.gcp_auth when the google-auth package is not installed. The module unconditionally imports google.oauth2.service_account and google.auth in a try/except and converts ImportError into this actionable message. Anything that pulls in a GCP-related provider (Vertex AI embedder, Vertex AI vector search, Gemini via service account) will fail at import with this error.
Source
Thrown at mem0/utils/gcp_auth.py:10
import os
import json
from typing import Optional, Dict, Any
try:
from google.oauth2 import service_account
from google.auth import default
import google.auth.credentials
except ImportError:
raise ImportError("google-auth is required for GCP authentication. Install with: pip install google-auth")
class GCPAuthenticator:
"""
Centralized GCP authentication handler that supports multiple credential methods.
Priority order:
1. service_account_json (dict) - In-memory service account credentials
2. credentials_path (str) - Path to service account JSON file
3. Environment variables (GOOGLE_APPLICATION_CREDENTIALS)
4. Default credentials (for environments like GCE, Cloud Run, etc.)
"""
@staticmethod
def get_credentials(
service_account_json: Optional[Dict[str, Any]] = None,
credentials_path: Optional[str] = None,
scopes: Optional[list] = NoneView on GitHub (pinned to 001c235229)
Solutions
- pip install google-auth in the active environment
- Better: install the provider's full extra, e.g. pip install 'mem0ai[google]' or add google-auth to requirements.txt alongside the vertexai packages
- Verify with python -c "import google.oauth2.service_account"
- If using Docker, rebuild the image after adding the dependency
Example fix
# before: ImportError: google-auth is required ... from mem0 import Memory # after # pip install google-auth google-cloud-aiplatform from mem0 import Memory
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec('google.oauth2.service_account') is None:
raise ConfigError('google-auth missing — pip install google-auth before using GCP providers') Try / catch
try:
from mem0.utils import gcp_auth
except ImportError as e:
if 'google-auth is required' in str(e):
raise ConfigError('add google-auth to requirements') from e
raise Prevention
- Declare google-auth (and vertexai/genai) in requirements whenever GCP providers are configured
- Fail dependency checks at container build time, not request time
- Keep one requirements file per deployment target so extras are not forgotten
When it happens
Trigger: Importing mem0.embeddings.vertexai or mem0.vector_stores.vertex_ai_vector_search (which transitively import gcp_auth) in an environment without google-auth; a fresh install of mem0ai without extras; a CI image that only installs the core package.
Common situations: Using Vertex AI config without installing GCP extras; dependency conflicts where pip resolved google-auth out; multiple virtualenvs and running from the wrong one.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Could not import reranker for provider '{provider_name}': {e
- google-cloud-aiplatform is required for Vertex AI. Install w
- google-genai is required. Install with: pip install google-g
- The '@aws-sdk/client-bedrock-runtime' package is required to
- The '@databricks/sql' package is required to use the Databri
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/f763f5b0ec846511.
Report an issue: GitHub.