kotartemiy / pygooglenews

If Google News had a Python library
https://newscatcherapi.com
MIT License
1.26k stars 134 forks source link

ImportError: cannot import name 'GoogleNews' from partially initialized module 'pygooglenews' #20

Open wzxtzqrl opened 2 years ago

wzxtzqrl commented 2 years ago

Hello, I'm having problem with running pygooglenews. My error result as follows:

Traceback (most recent call last):

File "C:\pygooglenews.py", line 1, in from pygooglenews import GoogleNews

ImportError: cannot import name 'GoogleNews' from partially initialized module 'pygooglenews' (most likely due to a circular import) (C:\pygooglenews.py)

Here's my code :

from pygooglenews import GoogleNews gn = GoogleNews() search = gn.search('lockdown') print(search)

pasenidis commented 2 years ago

Be careful when naming the filenames - Python takes them into account too.

pygooglenews.py has the exact same name with the module you're trying to import the class from. (pygooglenews), this confuses the interpreter, which makes it import GoogleNews from your file.

It is recommended that you rename pygooglenews.py to something like app.py to avoid future problems.