xtekky/gpt4free · warning · MissingRequirementsError

Google requires a browser to be installed.

Error message

Google requires a browser to be installed.

What it means

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.

Source

Thrown at g4f/Provider/search/GoogleSearch.py:31

class GoogleSearch(AsyncGeneratorProvider, AuthFileMixin):
    label = "Google Search"
    url = "https://google.com"
    working = has_nodriver
    use_nodriver = True

    @classmethod
    async def create_async_generator(
        cls,
        model: str,
        messages: Messages,
        browser: Browser = None,
        proxy: str = None,
        timeout: int = 300,
        **kwargs,
    ) -> AsyncResult:
        if not has_nodriver:
            raise MissingRequirementsError("Google requires a browser to be installed.")
        if not cls.working:
            raise ModelNotFoundError(f"Model {model} not found.")
        try:
            stop_browser = None
            if browser is None:
                browser, stop_browser = await get_nodriver(proxy=proxy, timeout=timeout)
            tab = await browser.get(cls.url)
            await asyncio.sleep(3)
            while True:
                try:
                    await tab.wait_for('[aria-modal="true"]', timeout=10)
                    await tab.wait_for(
                        '[aria-modal="true"][style*="display: none"]', timeout=timeout
                    )
                except Exception as e:
                    break
                break
            element = await tab.wait_for("textarea")

View on GitHub (pinned to 973504e177)

Solutions

  1. Install the web extra: pip install -U g4f[web] (pulls in nodriver)
  2. Or install directly: pip install -U nodriver
  3. Ensure a Chrome/Chromium binary exists on the system (nodriver needs one even headless)
  4. If you cannot install a browser, use the DDGS search provider instead

Example fix

# before
pip install g4f

# after
pip install -U "g4f[web]"
Defensive patterns

Strategy: validation

Validate before calling

def google_search_available() -> bool:
    try:
        import nodriver  # noqa: F401
        import shutil
        return bool(shutil.which("google-chrome") or shutil.which("chromium") or shutil.which("chromium-browser"))
    except ImportError:
        return False

Type guard

def has_nodriver() -> bool:
    try:
        import nodriver
        return True
    except ImportError:
        return False

Try / catch

from g4f.errors import MissingRequirementsError
try:
    async for r in GoogleSearch.create_async_generator(model, messages):
        ...
except MissingRequirementsError as e:
    if "browser" in str(e):
        logger.info("falling back to DDGS search (no browser installed)")
        async for r in DDGS.create_async_generator(model, messages):
            ...
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/21c2a9b3ecd65f50. Report an issue: GitHub.