Forum Archive

urllib.request works on Pythonista but not MacBook

hewjet

My exact code is:

with urllib.request.urlopen("https://asx.com.au") as response:
cod-response.read()
{SSL:CERTIFICATE_VERIFY_FAILED}

I HAVE TRIED TURNING OFF FIREWALL AND SSL VARIATIONS TO NO AVAIL

JonB

See
https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error

You might try the solution that mentions the lack of any certificates on osx, and suggests you install certifi. The other alternatives should also work (monkey patching ssl module, etc), but then you won't be verifying certificates.

hewjet

context=ssl.create.unverified_context() won't work. Giving:

module 'ssl' has no attribute 'create_unverified_context'

mikael

@hewjet, is there a reason not to use requests?

hewjet

There is no request module and no certifi module on MacBook

hewjet

By that I mean there is no requests module on MacBook

hewjet

Certifi won't download and unzip

mikael

@hewjet, pip install requests?