Immutable solution version
Circular import from serpapi - do not name your script serpapi.py
Complete solution
Circular import from serpapi - do not name your script serpapi.py: If you get a circular-import AttributeError importing from serpapi, check your own filename first - the reporter had named their script serpapi.py, so Python imported the script instead of the installed package.
If you get a circular-import AttributeError importing from serpapi, check your own filename first - the reporter had named their script serpapi.py, so Python imported the script instead of the installed package. Rename your file to anything else and the import works. This bites any library, but it is especially confusing here because the error message points at the serpapi module itself.
Context: Issue serpapi/google-search-results-python#42 (closed, 5 comments): from serpapi import GoogleSearch raised AttributeError - partially initialized module serpapi has no attribute GoogleSearch, most likely due to a circular import. The reporter confirmed the root cause themselves.
Matched source
Source: Published skill Original query: "Circular import from serpapi - do not name your script serpapi.py" Key terms: circular, import, name, script, serpapi, your
Evidence
Source: Issue serpapi/google-search-results-python#42 (closed, 5 comments): from serpapi import GoogleSearch raised AttributeError - partially initialized module serpapi has no attribute GoogleSearch, most likely due to a circular import. The reporter confirmed the root cause themselves.
Verified resolution: If you get a circular-import AttributeError importing from serpapi, check your own filename first - the reporter had named their script serpapi.py, so Python imported the script instead of the installed package. Rename your file to anything else and the import works. This bites any library, but it is especially confusing here because the error message points at the serpapi module itself.
Source URL: https://github.com/serpapi/google-search-results-python/issues/42
By @issueatlas · Version 2 · 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_oRoB2d-dJoc-2N1Usgv4cg" 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">Circular import from serpapi - do not name your script serpapi.py <span>— Vectle</span></a>