{"record":{"id":"21c2a9b3ecd65f50","repo":"xtekky/gpt4free","slug":"google-requires-a-browser-to-be-installed","errorCode":null,"errorMessage":"Google requires a browser to be installed.","messagePattern":"Google requires a browser to be installed\\.","errorType":"exception","errorClass":"MissingRequirementsError","httpStatus":null,"severity":"warning","filePath":"g4f/Provider/search/GoogleSearch.py","lineNumber":31,"sourceCode":"\nclass GoogleSearch(AsyncGeneratorProvider, AuthFileMixin):\n    label = \"Google Search\"\n    url = \"https://google.com\"\n    working = has_nodriver\n    use_nodriver = True\n\n    @classmethod\n    async def create_async_generator(\n        cls,\n        model: str,\n        messages: Messages,\n        browser: Browser = None,\n        proxy: str = None,\n        timeout: int = 300,\n        **kwargs,\n    ) -> AsyncResult:\n        if not has_nodriver:\n            raise MissingRequirementsError(\"Google requires a browser to be installed.\")\n        if not cls.working:\n            raise ModelNotFoundError(f\"Model {model} not found.\")\n        try:\n            stop_browser = None\n            if browser is None:\n                browser, stop_browser = await get_nodriver(proxy=proxy, timeout=timeout)\n            tab = await browser.get(cls.url)\n            await asyncio.sleep(3)\n            while True:\n                try:\n                    await tab.wait_for('[aria-modal=\"true\"]', timeout=10)\n                    await tab.wait_for(\n                        '[aria-modal=\"true\"][style*=\"display: none\"]', timeout=timeout\n                    )\n                except Exception as e:\n                    break\n                break\n            element = await tab.wait_for(\"textarea\")","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/search/GoogleSearch.py#L13-L49","documentation":"MissingRequirementsError raised by GoogleSearch (GoogleSearch.py:31) when has_nodriver is False — the 'nodriver' package (undetected Chrome automation) is not installed. Google search in g4f runs through a real browser via nodriver, so without it the provider cannot start; the check fires before any browser launch.","triggerScenarios":"Calling GoogleSearch.create_async_generator (e.g. a request routed to Google search) in an environment where 'import nodriver' failed at module load; also raised paths check cls.working right after, but this specific error is purely the missing dependency.","commonSituations":"Base g4f install without the web extra; headless servers with no Chrome installed (nodriver needs a Chrome/Chromium binary too); CI environments trimming GUI dependencies.","solutions":["Install the web extra: pip install -U g4f[web] (pulls in nodriver)","Or install directly: pip install -U nodriver","Ensure a Chrome/Chromium binary exists on the system (nodriver needs one even headless)","If you cannot install a browser, use the DDGS search provider instead"],"exampleFix":"# before\npip install g4f\n\n# after\npip install -U \"g4f[web]\"","handlingStrategy":"validation","validationCode":"def google_search_available() -> bool:\n    try:\n        import nodriver  # noqa: F401\n        import shutil\n        return bool(shutil.which(\"google-chrome\") or shutil.which(\"chromium\") or shutil.which(\"chromium-browser\"))\n    except ImportError:\n        return False","typeGuard":"def has_nodriver() -> bool:\n    try:\n        import nodriver\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"from g4f.errors import MissingRequirementsError\ntry:\n    async for r in GoogleSearch.create_async_generator(model, messages):\n        ...\nexcept MissingRequirementsError as e:\n    if \"browser\" in str(e):\n        logger.info(\"falling back to DDGS search (no browser installed)\")\n        async for r in DDGS.create_async_generator(model, messages):\n            ...\n    else:\n        raise","preventionTips":["Install the web extra in environments meant to use Google search: pip install -U g4f[web]","Ensure Chrome/Chromium is present on servers — nodriver needs the binary","Provide DDGS as a fallback provider when browsers aren't allowed"],"tags":["search","google","nodriver","dependencies"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}