mattharrison / effective_xgboost_book

268 stars 30 forks source link

SSL: CERTIFICATE_VERIFY_FAILED] error and proposed fix #19

Open davorborcic opened 3 months ago

davorborcic commented 3 months ago

I am getting the following error URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)>

based on my research it can be fixed by creating the SSL default context and then including the context parameter into the urllib.request.urlopen() call

import certifi
import ssl
context = ssl.create_default_context(cafile=certifi.where())

fin = urllib.request.urlopen(url, context=context)