Jacob
Jacob

Reputation: 263

Module not found Error when using Google Search API (SERPAPI)

When I run this example code on my local machine:

from serpapi import GoogleSearch

params = {
  "api_key": "secret_api_key",
  "engine": "google",
  "q": "Coffee",
  "location": "Austin, Texas, United States",
  "google_domain": "google.com",
  "gl": "us",
  "hl": "en"
}

search = GoogleSearch(params)
results = search.get_dict()

I get the error:

ModuleNotFoundError: No module named 'serpapi'

I can't find anything on Google/Bing search nor the documentation on how to go about installing this module or where it is even located. It does not respond to a pip install.

Upvotes: 6

Views: 20595

Answers (4)

user28726146
user28726146

Reputation: 1

You can try: from serpapi.google_search import GoogleSearch

It works for me, and hope it helps.

Upvotes: 0

user28257201
user28257201

Reputation: 1

Hi I was having the same problem. I did these two things, one of these worked. I'll drop the code.

pip install google-search-results
pip install google-serp-api

I don't know which one was it, because I ran them together, but this should work. I had previously tried google-search-results but it didn't work so should be the latter that helped, but just wanted to drop.

Upvotes: 0

Fred
Fred

Reputation: 31

I was having the same issue even after installing google-search-results

Problem: the selected interpreter on pycharm was on a different virtual environment that did not have Google-search installed

Solution: on your IDE add/select interpreter from working directory/virtual env where google-search-results was installed

Upvotes: 3

Shubham Chaudhari
Shubham Chaudhari

Reputation: 211

Use can use the below command to solve the above issue \

pip install google-search-results

You can find more details on the GitHub link

Upvotes: 21

Related Questions