AttributeError during the import of the module: `initialized module 'serpapi' has no attribute 'GoogleSearch' (most
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
- 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