mattlisiv / newsapi-python

A Python Client for News API
MIT License
403 stars 139 forks source link

TypeError: super(type, obj): obj must be an instance or subtype of type #22

Closed ghaith99 closed 5 years ago

ghaith99 commented 6 years ago

When I run: api.get_everything(q='bitcoin')

I get api.get_everything(q='bitcoin') Traceback (most recent call last):

File "", line 1, in api.get_everything(q='bitcoin')

File "C:\Users\LapLap\Anaconda3\envs\fluffy\lib\site-packages\newsapi\newsapi_client.py", line 248, in get_everything r = requests.get(const.EVERYTHING_URL, auth=self.auth, timeout=30, params=payload)

File "C:\Users\LapLap\Anaconda3\envs\fluffy\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs)

File "C:\Users\LapLap\Anaconda3\envs\fluffy\lib\site-packages\requests\api.py", line 57, in request with sessions.Session() as session:

File "C:\Users\LapLap\Anaconda3\envs\fluffy\lib\site-packages\requests\sessions.py", line 386, in init self.mount('https://', HTTPAdapter())

File "C:\Users\LapLap\Anaconda3\envs\fluffy\lib\site-packages\requests\adapters.py", line 120, in init super(HTTPAdapter, self).init()

TypeError: super(type, obj): obj must be an instance or subtype of type

mattlisiv commented 6 years ago

Hi @ghaith99 ,

I can't seem to recreate this issue.

How is it that you are initializing your client?

Thanks, Matt

BiplabGhosal commented 6 years ago

Hi @mattlisiv,

Just like commented by @ghaith99 , I am getting the same error. Am initializing the client based on an API key I received in email.

For testing purpose, am just running the get_sources() as of now.

r0f1 commented 6 years ago

Hi, I get the same issue as described. I tried the following piece of code:

import requests
url = ('https://newsapi.org/v2/top-headlines?'
       'country=us&'
       'apiKey=MY_API_KEY')
response = requests.get(url)
print(response.json())

EDIT: Using

curl 'https://newsapi.org/v2/everything?q=bitcoin&from=2018-09-30&sortBy=publishedAt&apiKey=MY_API_KEY'

works though.

EDIT2: Ok I tracked it down. It seems that there is an issue using requests inside Jupyter notebooks. Try using requests or the newsapi-python package outside of Jupyter notebooks and it should work.