ggOlle
ggOlle

Reputation: 93

Error when news scraping with GoogleNews - "No module named GoogleNews"

I'm trying to use the GoogleNews API which was recently released to get some articles from google, provided by this website https://pypi.org/project/GoogleNews/.

But in the terminal i get the error "No module named 'GoogleNews' ", even though I've run the

pip install GoogleNews

Here's the full program I'm trying to run:

from GoogleNews import GoogleNews
googlenews = GoogleNews()

googlenews.search('Corona')

googlenews.result()

Is it something I'm missing? Pretty damn new to assess if APIs are good/working/not working etc.

Is there something that you guys usually look for when trying to find a tool to get for example news as easily as possible?

Upvotes: 2

Views: 2902

Answers (1)

O'Niel
O'Niel

Reputation: 1773

It could be possible that you're messing up the Python versions.

If you install a module using pip you should execute your Python code with Python 2.7. If you want to use Python version 3 you need to use pip3 and execute your code using python3 myScript.py.

Try the following:

  1. Make a file called myScript.py
from GoogleNews import GoogleNews
googlenews = GoogleNews()

googlenews.search('Corona')

googlenews.result()
  1. Install the GoogleNews module
pip3 install GoogleNews
  1. Execute your code
python3 myScript.py

If you don't have Python 3 yet, download it here. Pip3 comes automatically with Python 3.

Upvotes: 2

Related Questions