ModuleNotFoundError: No module named 'google'
Asked Answered
S

4

10

Once I am trying to use google search api it's showing me an error:

Traceback (most recent call last):
  File "C:\Users\Maor Ben Lulu\Desktop\Maor\Python\google\google_Bot.py", line 1, in <module>
    from google import google
ModuleNotFoundError: No module named 'google'

My code :

from google import google
import urllib.request
import time
from bs4 import BeautifulSoup

def google_scrape(url):
    thepage = urllib.request.urlopen(url)
    soup = BeautifulSoup(thepage, "html.parser")
#    print(soup.prettify())
    return soup.prettify()
### Rest of the code

I did:

pip install google

But still doesn't work.

Spartan answered 27/8, 2018 at 11:59 Comment(7)
I would like to advice you: if you are going to use google data, you have to use their API .. I tried everything before and nothing works or it works but they block your IP after small time, even if you use these informal packagesBlackjack
do you have two python versions installed? and are you sure you did "pip install" using an Administrative CMD window?Bluebird
What do you get when you run pip list?Virtues
How many versions of python have you got? Are oyu sure you did pip install on the right version? To check if you have the google module, you can run this command help('modules') To see all availaible modules.Myotonia
@Virtues google 2.0.1 google-api-python-client 1.7.4 google-auth 1.5.1 google-auth-httplib2 0.0.3 google-cloud 0.34.0 google-search 1.0.2Spartan
Did pip install the libraries for the right interpretor? The best way to know is to run print(help('modules')) in your codeMyotonia
Possible duplicate of ImportError after successful pip installationProvidenciaprovident
S
9

This will solve you issue But you have to do import google not from google import google

pip install --upgrade google-api-python-client
Shotton answered 2/11, 2020 at 3:17 Comment(0)
M
2

Install below mentioned package

pip install google-cloud
Mindi answered 18/10, 2018 at 7:33 Comment(0)
P
0

My problem was a virtual env and shebang: I used absolute path shebang on Debian 12, like #!/usr/bin/python3, and it ignored active virtualenv.
#!/usr/bin/env python worked, because it uses python from virtualenv, not systemwide.

See What shebang to use for Python scripts run under a pyenv virtualenv

Provencher answered 18/3 at 10:55 Comment(0)
S
-1
pip install google-cloud-bigquery
Subauricular answered 18/4, 2019 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.