Importerror: Cannot Import Name 'Search' from 'Google' (Unknown Location)

I'm trying to repurpose some old code I found from 3 years ago, where it grabs text using an OCR, then Googles what it found.

In the original code, it imports the google package using from google import google, and then using google.search(). However, when I try it today, I'm getting this error traced to the line the package gets imported.

ImportError: cannot import name 'google' from 'google' (unknown location)

Now, I'm assuming that at the time, this worked fine, but considering Google is Google, the process I need to follow today is different from what it was 3 years ago. My guess is that googlesearch should be the package I need to use, or that I need to define the location google is installed to in the code, but I'm not exactly sure what needs to be done to make it work, even after searching for the issue for hours. Any tips and suggestions would help tons.

1 Answer

I would install googlesearch using python3 -m pip googlesearch-python

Then the function is simple to call.

from googlesearch import search
search("foo")
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest