0

I had installed a module with the command pip install google. It worked file but when I try to run files with this module it gives error.

The image of error

My code:-

from google import search

ip=raw_input("What would you like to search for? ")

for url in search(ip, stop=20):
     print(url)

I have already installed google.

enter image description here

What am I doing wrong here?

Notes:-

  1. I have only 1 python installed (Python 3.9.5)
  2. Even after using command python -m pip install google it doesn't work. Image- Module not found

Thank you!

  • Maybe you have several `python`s installed, and when invoking the script you are using the one which does not have a package. Try `sys.executable` from within your script, to see what interpreter is used. (See this answer https://stackoverflow.com/questions/2589711/find-full-path-of-the-python-interpreter) – selyunin Jun 07 '21 at 10:44
  • Have you had a look at [this](https://stackoverflow.com/questions/36183486/importerror-no-module-named-google)? – user42 Jun 07 '21 at 13:07

2 Answers2

2

If you have more than 1 python installed, there is chance pip installed google in different python. To make sure it does install module for python you are using do:

python -m pip install google

Then try running your code again. If you want to know more about installing you might read Installing Python Modules.

Daweo
  • 31,313
  • 3
  • 12
  • 25
  • I did that command too, pls check the edited question. And I did not understand what are you telling about "several pythons" I have only 1 installed Python-3.9.5 – Dr. Strange Codes Jun 07 '21 at 12:05
  • But your code example contains `raw_input` and `raw_input` doesn't exist in Python 3. If you present us code for Python 2 and error messages from Python 3 we have to assume that you have at least 2 different versions of Python installed. – Matthias Jun 14 '21 at 06:37
0

Yes I found myself the solution. Thanks to @user42 for the link. I used this command and it worked.

pip install --upgrade google-api-python-client

I have put the answer because it may help people who are facing or will be facing the same problem.