Python Forum

Full Version: Using Quandl and Python3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried to run the following code that uses the python module for Quandl. This came right out of a textbook on machine learning.

I did not use an authentication token because the sample code did not.

Anyway it generated an error. As shown.

But it was exactly from the textbook.

See the output shown below.


python3 
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import quandl
>>> mydata = quandl.get("YAHOO/INDEX_DJI", start_date="2005-12-01",end_date="2005-12-05")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/james/.local/lib/python3.5/site-packages/quandl/get.py", line 48, in get
    data = Dataset(dataset_args['code']).data(params=kwargs, handle_column_not_found=True)
  File "/home/james/.local/lib/python3.5/site-packages/quandl/model/dataset.py", line 47, in data
    return Data.all(**updated_options)
  File "/home/james/.local/lib/python3.5/site-packages/quandl/operations/list.py", line 15, in all
    r = Connection.request('get', path, **options)
  File "/home/james/.local/lib/python3.5/site-packages/quandl/connection.py", line 38, in request
    return cls.execute_request(http_verb, abs_url, **options)
  File "/home/james/.local/lib/python3.5/site-packages/quandl/connection.py", line 42, in execute_request
    session = cls.get_session()
  File "/home/james/.local/lib/python3.5/site-packages/quandl/connection.py", line 58, in get_session
    adapter = HTTPAdapter(max_retries=cls.get_retries())
  File "/home/james/.local/lib/python3.5/site-packages/quandl/connection.py", line 74, in get_retries
    raise_on_status=False)
TypeError: __init__() got an unexpected keyword argument 'raise_on_status'
How do I fix this error? Remember it came from a textbook.

Any help appreciated. Thanks.

Respectfully,

ErnstTBass



















[/code]
Okay, I think that I know what the error is. It is looking to get the Quandl Authorization token and it is not finding it.

It needs something like

quandl.ApiConfig.api_key = "YOURAPIKEY" (with of course the YOURAPIKEY replaced by quandl authorization token)

to be inserted in the next line after import quandl line

However, even when I do this I still get the error.

I am beginning to believe that the auth token has a limited lifetime and I did not
use it quickly enough.

My auth token is 20 characters long and it includes numbers and letters (some small and some capital).

How do get this thing to work?

Respectfully,

ErnestTBass
A simple script:

#!/usr/bin/python3
import requests
key = "xxxxxxxxx" # key is free
  
tic = "euronext/ibma"
url = "https://www.quandl.com/api/v3/datasets/"+tic+"?rows=1&api_key="+key
 
rsp = requests.get(url)
if rsp.status_code in (200,):
    ustr = rsp.text.strip()
    print(ustr)
else:
    print("ERROR:", rsp.status_code)
    print(rsp.text)