{"record":{"id":"0ebd2e1282026327","repo":"FoundationAgents/MetaGPT","slug":"to-use-this-module-you-should-have-the-duckduckg","errorCode":null,"errorMessage":"To use this module, you should have the `duckduckgo_search` Python package installed. You can install it by running the command: `pip install -e.[search-ddg]`","messagePattern":"To use this module, you should have the `duckduckgo_search` Python package installed\\. You can install it by running the command: `pip install -e\\.\\[search-ddg\\]`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"metagpt/tools/search_engine_ddg.py","lineNumber":15,"sourceCode":"#!/usr/bin/env python\n\nfrom __future__ import annotations\n\nimport asyncio\nimport json\nfrom concurrent import futures\nfrom typing import Literal, Optional, overload\n\nfrom pydantic import BaseModel, ConfigDict\n\ntry:\n    from duckduckgo_search import DDGS\nexcept ImportError:\n    raise ImportError(\n        \"To use this module, you should have the `duckduckgo_search` Python package installed. \"\n        \"You can install it by running the command: `pip install -e.[search-ddg]`\"\n    )\n\n\nclass DDGAPIWrapper(BaseModel):\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n\n    loop: Optional[asyncio.AbstractEventLoop] = None\n    executor: Optional[futures.Executor] = None\n    proxy: Optional[str] = None\n\n    @property\n    def ddgs(self):\n        return DDGS(proxies=self.proxy)\n\n    @overload\n    def run(","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/tools/search_engine_ddg.py#L1-L33","documentation":"Module-level ImportError raised while importing metagpt.tools.search_engine_ddg: the optional duckduckgo_search package is not installed, so the module cannot define DDGS and refuses to load. This fails at import time, not at search time, because the try/except sits at top level.","triggerScenarios":"import metagpt.tools.search_engine_ddg or configuring DDGAPIWrapper as the search engine in a MetaGPT install lacking the search-ddg extra.","commonSituations":"Core `pip install metagpt` without extras; choosing DuckDuckGo as the default SearchEngine in config; CI image without optional deps.","solutions":["Install the extra: pip install -e.[search-ddg]","Verify: python -c \"import duckduckgo_search\"","Or switch config to a search engine whose dependencies you already have"],"exampleFix":"# before: ImportError on import\nfrom metagpt.tools.search_engine_ddg import DDGAPIWrapper\n# after\n# pip install -e.[search-ddg]\nfrom metagpt.tools.search_engine_ddg import DDGAPIWrapper","handlingStrategy":"fallback","validationCode":"try:\n    import duckduckgo_search  # noqa: F401\n    ok = True\nexcept ImportError:\n    ok = False","typeGuard":null,"tryCatchPattern":"try:\n    from metagpt.tools.search_engine_ddg import DDGAPIWrapper\nexcept ImportError:\n    from metagpt.tools.search_engine_serper import SerperWrapper  # substitute engine","preventionTips":["Install the search extra matching your configured engine in one setup step","Import search engine modules lazily inside a try block at startup","Pin optional extras in requirements to keep environments consistent"],"tags":["optional-dependency","import-error","search","duckduckgo"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}