[SSL: CERTIFICATE_VERIFY_FAILED]的解决方案

问题描述

在Python Machine Learning(2nd) chapter 2 中有

 import pandas as pd 
 df=pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data',header=None)

执行过程中会遇到

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1051)

原因和解决方案

具体不清楚问题出现在哪里,但是总体来说就是证书出现了问题,为了解决这个问题,需要更新证书:

在终端中输入(OS系统):

sudo /Applications/Python\ 3.7/Install\ Certificates.command

如果是3.6 的python,里面的3.7就改为3.6,执行之后就可以得到

Requirement already up-to-date: certifi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2018.11.29)
 -- removing any existing file or link
 -- creating symlink to certifi certificate bundle
 -- setting permissions
 -- update complete

然后就可以了

你可能感兴趣的:(烦死小白的bug)