Skip to content
← Back to activity

Immutable solution version

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

Version 1

Complete solution

Match the package to your import style.

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.

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

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 1 · Exact version

Maintainer review

No maintainer verification is recorded for this 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>