{"record":{"id":"368d3eb469d69fcd","repo":"FoundationAgents/MetaGPT","slug":"to-use-this-module-you-should-have-the-google-ap","errorCode":null,"errorMessage":"To use this module, you should have the `google-api-python-client` Python package installed. You can install it by running the command: `pip install -e.[search-google]`","messagePattern":"To use this module, you should have the `google-api-python-client` Python package installed\\. You can install it by running the command: `pip install -e\\.\\[search-google\\]`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"metagpt/tools/search_engine_googleapi.py","lineNumber":18,"sourceCode":"#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import annotations\n\nimport asyncio\nimport json\nimport warnings\nfrom concurrent import futures\nfrom typing import Optional\nfrom urllib.parse import urlparse\n\nimport httplib2\nfrom pydantic import BaseModel, ConfigDict, model_validator\n\ntry:\n    from googleapiclient.discovery import build\nexcept ImportError:\n    raise ImportError(\n        \"To use this module, you should have the `google-api-python-client` Python package installed. \"\n        \"You can install it by running the command: `pip install -e.[search-google]`\"\n    )\n\n\nclass GoogleAPIWrapper(BaseModel):\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n\n    api_key: str\n    cse_id: str\n    discovery_service_url: Optional[str] = None\n\n    loop: Optional[asyncio.AbstractEventLoop] = None\n    executor: Optional[futures.Executor] = None\n    proxy: Optional[str] = None\n\n    @model_validator(mode=\"before\")\n    @classmethod","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/tools/search_engine_googleapi.py#L1-L36","documentation":"Module-level ImportError raised while importing metagpt.tools.search_engine_googleapi: googleapiclient.discovery (provided by google-api-python-client) is not installed. Like the DDG module, it fails on import, so merely referencing the module in config can crash a run.","triggerScenarios":"import metagpt.tools.search_engine_googleapi or setting GoogleAPIWrapper as the search provider without the search-google extra installed.","commonSituations":"Core-only MetaGPT install; switching SearchEngine to 'GoogleAPIWrapper' in config without adding deps; fresh environment built from a slim requirements list.","solutions":["Install the extra: pip install -e.[search-google]","Verify: python -c \"from googleapiclient.discovery import build\"","Or use an already-installed engine (e.g. serper/serpapi) instead"],"exampleFix":"# before: ImportError on import\nfrom metagpt.tools.search_engine_googleapi import GoogleAPIWrapper\n# after\n# pip install -e.[search-google]\nfrom metagpt.tools.search_engine_googleapi import GoogleAPIWrapper(api_key=..., cse_id=...)","handlingStrategy":"fallback","validationCode":"try:\n    from googleapiclient.discovery import build  # noqa: F401\n    ok = True\nexcept ImportError:\n    ok = False","typeGuard":null,"tryCatchPattern":"try:\n    from metagpt.tools.search_engine_googleapi import GoogleAPIWrapper\nexcept ImportError:\n    from metagpt.tools.search_engine_ddg import DDGAPIWrapper  # fallback engine","preventionTips":["Install search-google extra before switching config to googleapi","Lazy-import engine modules and fail with an actionable message","Smoke-test engine imports in CI for every engine your config can select"],"tags":["optional-dependency","import-error","search","google"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}