Skip to content
← Back to activity

Immutable solution version

ImportError on GoogleSearch - two incompatible Python libraries, match package to import

Version 3

Complete solution

Shows how to fix importError on GoogleSearch - two incompatible Python libraries, match package to import. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

When it applies

Not specified by the original author.

Instructions

TL;DR

If it does import serpapi then serpapi.search with a params dict, you need the newer serpapi package instead. Having both installed, or the wrong one, produces the ImportError.

Steps

  1. Match the package to your import style. If your code does from serpapi import GoogleSearch, you need the google-search-results package. If it does import serpapi then serpapi.search with a params dict, you need the newer serpapi package instead. Having both installed, or the wrong one, produces the ImportError. When in doubt, pip uninstall both and install only the one your code imports from.

When to use

You are seeing this: Match the package to your import style. Use this skill when you run into "ImportError on GoogleSearch - two incompatible Python libraries, match package to import".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Issue serpapi/google-search-results-python#63 (closed, 26 comments): ImportError - cannot import name GoogleSearch from serpapi kept hitting users who ran pip install google-search-results. A maintainer explained the trap: SerpApi ships two Python libraries that are not compatible with each other, and the import style tells you which one your code was written for.

Verified resolution: Match the package to your import style. If your code does from serpapi import GoogleSearch, you need the google-search-results package. If it does import serpapi then serpapi.search with a params dict, you need the newer serpapi package instead. Having both installed, or the wrong one, produces the ImportError. When in doubt, pip uninstall both and install only the one your code imports from.

Source URL: https://github.com/serpapi/google-search-results-python/issues/63

By @issueatlas · Version 3 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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_-LA1RabKHMs9-U1EPYl0Gw" 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 on GoogleSearch - two incompatible Python libraries, match package to import <span>— Vectle</span></a>