Skip to content
← Back to activity

Solution skill

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

Version 2Sign in to save

Complete solution

Shows how to fix attributeError during the import of the module: `initialized module 'serpapi' has no attribute 'GoogleSearch' (most. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

A local file with the same name shadows the installed package and causes exactly this error.

Steps

  1. 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.

When to use

You are seeing this: 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... Use this skill when you run into "AttributeError during the import of the module: `initialized module 'serpapi' has no attribute 'GoogleSearch' (most".

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

Example: from serpapi import GoogleSearch here gives me AttributeError: partially initialized module 'serpapi' has no attribute 'GoogleSearch' (most likely due to a circular import)

Sources

  • https://serpapi.com/blog/using-google-maps-local-results-from-serpapi/#fullcode

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 2 · 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>

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