Closed dangerrockstar closed 6 years ago
@dangerrockstar,
are you using pip for installing the package?
yeah its add in my pip list but not working
Could you replace your import with:
from newsapi.newsapi_client import NewsApiClient
It might be that the namespace is missing from the import statement.
I'm having the same issue after using pip to install.
When I use "from newsapi import NewsApiClient" I get:
Traceback (most recent call last):
File "newsapi.org\newsapi.py", line 7, in
When I use "from newsapi.newsapi_client import NewsApiClient" i get:
Traceback (most recent call last):
File "newsapi.org\newsapi.py", line 7, in
@heedro,
It looks like you have named your script file "newsapi.py" . Is this correct?
If so, it can mix-up the namespace of the import statement. Try updating the filename and see if that resolves the issue.
Hi, I have the same problem. When I run the .py file, it always says "Import Error: cannot import name NewsApiClient." I want to add this api to google voice kit.
I cannot seem to replicate this issue.
I have attempted a fresh install for both Windows and Mac. If someone would like to upload their project or define their setup (Python version, OS, etc.), I would be happy to assist.
For now, I have created a new example project that uses Docker to do a fresh install of Python, pip, and the NewsApi library to retrieve top headlines. I hope this helps.
my error is caused by my script file name newsapi.py, after i changed the filename, it works normally. @mattlisiv thanks your point
from newsapi import NewsApiClient newsapi = NewsApiClient(api_key='e6702efb133e48418f78ea26f4620e20') top_headlines = newsapi.get_top_headlines(q='bitcoin', sources='bbc-news,the-verge', category='business', language='en', country='us')
getting error in python3.x ImportError: cannot import name 'NewsApiClient'