BOBTHEBUILDER
BOBTHEBUILDER

Reputation: 393

skipping ssl-verification for quandl in python

the problem is that i can't access quandl data with quandl.get() because it throws an SSLError.

i have tried setting verify = False, and some other things.
this is the code:

    data = quandl.get("EOD/MSFT", authtoken="gyX6Yqxx3xT3hsdSmPva", verify=False)

    Exception has occurred: requests.exceptions.SSLError
    HTTPSConnectionPool(host='www.quandl.com', port=443): Max retries exceeded with url: /api/v3/datasets/EOD/MSFT/data?order=asc&verify=True 
    (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
    File"C:\RILEYHQ\my_coding\PYTHON\script_files\graphing\financial\stock_price_data.py", line 29, in <module>
    data = quandl.get("EOD/MSFT", authtoken="gyX6Yqxx3xT3hsdSmPva", verify = True)

what is the cause an fix of an ssl error? is it to do with my internet, the code or the website?

Upvotes: 2

Views: 843

Answers (3)

Clark Updike
Clark Updike

Reputation: 190

Try setting this before your call:

quandl.ApiConfig.verify_ssl = False

That should disable SSL.

If you have a cacert bundle you want to use (e.g. for a proxy server), you can point to it using the same:

quandl.ApiConfig.verify_ssl = <path to cacert bundle>

I had to dig through the code to figure this out--not sure if I missed documentation on it somehow...

Upvotes: 2

StanTT
StanTT

Reputation: 21

I don't know if you still get that error after trying. My answer is it's not only because of the Internet connection, but also the version and how you set up SSL internally, so you need to reset PYTHONHTTPSVERIFY.

I added this block before acquiring https service, and that helped:

import os, ssl

if (not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None)):
    ssl._create_default_https_context = ssl._create_unverified_context 

Upvotes: 1

run-out
run-out

Reputation: 3184

I tried your code and got the same error. Then I tried it this way with your key and it worked. Not sure if it will work for you.

import quandl
quandl.ApiConfig.api_key = 'gyX6Yqxx3xT3hsdSmPva'
data = quandl.get("EOD/MSFT")
data

Upvotes: 1

Related Questions