SSL error on request API

Hello.
I have a problem with the SSL certificates on using the requests module on OSX Mojave.
I have done the following:

  • Installed python 3.7
  • pip installed the requests module (in 2.7 and also 3.7 version)
  • added the external module path in the prefference menu in TD
  • made a request by typing this code into a text DAT:

[code] import requests

url = ‘https://api.github.com/events
response = requests.get(url)

print (response) [/code]

And got this error:
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘api.github.com’, port=443): Max retries exceeded with url: /events (Caused by SSLError(SSLError(1, ‘[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645)’),))

What am I doing wrong???

Strange issue. I did some reading and the low hanging fruit would be to try running:

pip install ‘requests[security]’

for your Python 3 installation and then try running your request again. if that doesn’t work I can write some notes on potentially upgrading the OpenSSL version that ships with Mac, but doing a pip install is easier and affects your computer less.

Tried it. Still won’t work. Any other approaches?

UPDATE

The issue persist on all MAC OSX, older or new. I’ve did some tests. I’ve installed more than one version of python, but I think the problem lies somewhere in between the assigned path in the prefferences of TD, and the external path not being reached by the request.
When I fill that path with an adress and hit apply, I get this error in the textport. Can someone decode it by any chance? I think TD cannot acces the external python modules on macosx, or something like that.

Which older version of macOS did you try on? If possible, can you post what you tried and the error. I can try running it on some older macOS as well and report back.

I’ve tried on Sierra, High Sierra and El Capitan. On different computers. Same SSL error, AND the error above that I get if I leave the textport open while I change the python path in prefferences. I think that it’s something wrong on how TD interprets the external python path on macosX (even if it’s the 3.5 version or 3.7) , or if not, the Certificates issue.

Curious if this ever got solved. Seems like the issue is still around and lots of Mac users can’t use requests correctly.

Bump again, I still here people I teach that encounter the same issue. Is there an official work around or patch fix that can get them through this?

As a workaround you could try disabling SSL certificate verification in the get method. This is done using the verify keyword:

requests.get(url, verify=False)

realpython.com/python-requests/ … rification

1 Like

nope. disabling SSL cert doesn’t work. same errors. :frowning:

Hi! Did anyone fix this :frowning: ?