newsapi-python
newsapi-python copied to clipboard
Library Partial Import Error
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior. For instance:
-
conda activate venv
-
pip install newsapi_python
from newsapi import NewsApiClient
# Init
api = NewsApiClient(api_key='xxxxxxxxxxxx')
# /v2/everything
all_articles = api.get_everything(q='mars')
print(all_articles)
-
(venv) C:\Users\abc\anaconda3\envs\venv\bin>C:/Users/abc/anaconda3/envs/venv/python.exe
Expected behavior News Data
Screenshots
d:/Projects/advisely/advisely/API/newsapi.py
Traceback (most recent call last):
File "d:/Projects/newsoftoday/API/newsapi.py", line 3, in <module>
from newsapi import NewsApiClient
File "d:\Projects\newsoftoday\API\newsapi.py", line 3, in <module>
from newsapi import NewsApiClient
ImportError: cannot import name 'NewsApiClient' from partially initialized module 'newsapi' (most likely due to a circular import) (d:\Projects\newsoftoday\API\newsapi.py)
Desktop (please complete the following information):
- OS: Windows 10
- Visual Studio Code
- Version [1.57.1]
Additional context
(venv) C:\Users\abc\anaconda3\envs\venv\bin>pip install newsapi_python
Collecting newsapi_python
Using cached newsapi_python-0.2.6-py2.py3-none-any.whl (7.9 kB)
Requirement already satisfied: requests<3.0.0 in c:\users\abc\anaconda3\envs\venv\lib\site-packages (from newsapi_python) (2.25.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\abc\anaconda3\envs\venv\lib\site-packages (from requests<3.0.0->newsapi_python) (1.26.5)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\abc\anaconda3\envs\venv\lib\site-packages (from requests<3.0.0->newsapi_python) (2021.5.30)
Requirement already satisfied: idna<3,>=2.5 in c:\users\abc\anaconda3\envs\venv\lib\site-packages (from requests<3.0.0->newsapi_python) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\abc\anaconda3\envs\venv\lib\site-packages (from requests<3.0.0->newsapi_python) (4.0.0)
Installing collected packages: newsapi-python
Successfully installed newsapi-python-0.2.6
@BlueSkyTrading Quite possible that you have already figured it out on your own but I'll give it a try anyway - you should change name of your file newsapi.py
to something else to avoid modules names conflict.