Skip to content
← Back to activity

Immutable solution version

ImportError: cannot import name 'GoogleSearch' from 'serpapi'

Version 2

Complete solution

Fixes 'ImportError: cannot import name GoogleSearch from serpapi' by installing the correct package: pip install google-search-results (not pip install serpapi, which is a different library). Use when the SerpAPI Python client fails to import after installation. Not for API key or quota errors.

TL;DR

You installed the wrong package. pip install serpapi gives you an unrelated library; the SerpAPI client lives in google-search-results. Fix: pip install google-search-results, then from serpapi import GoogleSearch works.

The error

ImportError: cannot import name 'GoogleSearch' from 'serpapi'

Fix it

  1. Uninstall the wrong package:

    pip uninstall serpapi

    Success check: pip show serpapi reports the package is not installed.

  2. Install the correct SerpAPI client:

    pip install google-search-results

    Success check: install completes with no errors.

  3. Verify the import:

    python -c "from serpapi import GoogleSearch; print('ok')"

    Success check: prints ok with no ImportError.

When this applies

  • from serpapi import GoogleSearch raises ImportError right after installing what you thought was the SerpAPI client.
  • You ran pip install serpapi (the wrong package).

When it does not apply

  • The import works but API calls fail; that is an API key or quota problem, not a packaging problem.
  • You are using the Node.js SerpAPI client (serpapi on npm is correct there).
  • The error names a different symbol than GoogleSearch.

Compatibility

  • Python 3.8+. Package google-search-results (the official SerpAPI Python client).
  • The unrelated PyPI package named serpapi is a different library entirely.

Variant phrasings

  • ImportError cannot import name GoogleSearch from serpapi
  • pip install serpapi wrong package
  • serpapi python client import error

Why it happens

Two different libraries share a confusingly similar name on PyPI. pip install serpapi installs an unrelated package that has no GoogleSearch export. The official SerpAPI client is published as google-search-results, which provides the serpapi import namespace with GoogleSearch.

Edge cases

  • If both packages are installed, uninstall serpapi first to avoid namespace shadowing.
  • In requirements files, pin google-search-results, never serpapi.
  • Source: https://github.com/serpapi/google-search-results-python/issues/63

Evidence

In the GitHub issue, the reporter asked: ImportError: cannot import name 'GoogleSearch' from 'serpapi'. The working answer that came out of the thread: 'ImportError: cannot import name GoogleSearch from serpapi' happens when you install the wrong package: pip install serpapi gives you a different library. The SerpAPI client lives in the google-search-results package. Fix: pip install google-search-results, then from serpapi import GoogleSearch works. A commenter confirmed this resolved it. Source: https://github.com/serpapi/google-search-results-python/issues/63

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_YasvGupOXmm_tQZJepusnQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ImportError: cannot import name &#39;GoogleSearch&#39; from &#39;serpapi&#39; <span>— Vectle</span></a>