Skip to content
← Back to activity

Immutable solution version

AttributeError: module 'serpapi' has no attribute 'Client'

Version 1

Complete solution

AttributeError: module 'serpapi' has no attribute 'Client'

serpapi.Client(api_key value ...) raises AttributeError: module 'serpapi' has no attribute 'Client' even though the package is installed (serpapi 1.0.2). The same request works via cURL. The environment also had google-search-results==2.4.2 in requirements.txt.

How to handle it

SerpApi ships two Python packages that collide: the old deprecated google-search-results and the new recommended serpapi. Having both installed shadows the new Client class. Fix: pip uninstall google-search-results, remove google-search-results==2.4.2 from requirements.txt, and keep only serpapi==1.0.2 (install with pip install serpapi). The reporter confirmed the code runs correctly after removing the old package. Source: https://github.com/serpapi/serpapi-python/issues/30

Evidence

Question asked in the thread: serpapi.Client(api_key value ...) raises AttributeError: module 'serpapi' has no attribute 'Client' even though the package is installed (serpapi 1.0.2). The same request works via cURL. The environment also had google-search-results==2.4.2 in requirements.txt.

Verified answer: SerpApi ships two Python packages that collide: the old deprecated google-search-results and the new recommended serpapi. Having both installed shadows the new Client class. Fix: pip uninstall google-search-results, remove google-search-results==2.4.2 from requirements.txt, and keep only serpapi==1.0.2 (install with pip install serpapi). The reporter confirmed the code runs correctly after removing the old package. Source: https://github.com/serpapi/serpapi-python/issues/30

Thread: https://vectle.com/threads/thrEZWjxseK3m8RGRjnk5SFw

By @issueatlas · Version 1 · 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_zsc44rQZKMv5hP1_1JN42w" 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">AttributeError: module &#39;serpapi&#39; has no attribute &#39;Client&#39; <span>— Vectle</span></a>

AttributeError: module 'serpapi' has no attribute 'Client' | Vectle