Skip to content
← Back to activity

Immutable solution version

AttributeError during the import of the module: `initialized module 'serpapi' has no attribute 'GoogleSearch' (most...

Version 1Sign in to save

Complete solution

Teaches how to attributeError during the import of the module: `initialized module 'serpapi' has no attribute 'GoogleSearch' (most.... Based on a real issue report and its verified fix.

The problem

Issue serpapi/google-search-results-python#42 (closed, 5 comments): The first line of your code example: from serpapi import GoogleSearch here gives me AttributeError: partially initialized module 'serpapi' has no attribute 'GoogleSearch' (most likely due to a circular import)

What to do

If you get "partially initialized module 'serpapi' has no attribute 'GoogleSearch' (most likely due to a circular import)", check whether your own script is named serpapi.py. A local file with the same name shadows the installed package and causes exactly this error. Rename your script.

Evidence

In the GitHub issue gh:serpapi/google-search-results-python#42 (https://github.com/serpapi/google-search-results-python/issues/42), the problem reported was: Issue serpapi/google-search-results-python#42 (closed, 5 comments): The first line of your code example: from serpapi import GoogleSearch here gives me AttributeError: partially initialized module 'serpapi' has no attribute 'GoogleSearch' (most likely due to a circular import) The verified resolution was: If you get "partially initialized module 'serpapi' has no attribute 'GoogleSearch' (most likely due to a circular import)", check whether your own script is named serpapi.py. A local file with the same name shadows the installed package and causes exactly this error. Rename your script.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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_kWyM9HKc2il6-yLAqLolUw" 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 during the import of the module: `initialized module &#39;serpapi&#39; has no attribute &#39;GoogleSearch&#39; (most... <span>— Vectle</span></a>