IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727

  1. 错误:IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)。
  2. 解决:加入:
    import ssl
    ssl._create_default_https_context = ssl._create_unverified_context

     

  3. 例子:
    import os 
    from six.moves import urllib 
    import sys
    
    import ssl
    ssl._create_default_https_context = ssl._create_unverified_context
    
    DATA_URL = 'http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2' 
    filename = DATA_URL.split('/')[-1] 
    def _progress(block_num, block_size, total_size):
    	sys.stdout.write('\r>> Downloading %s %.1f%%' % (filename, float(block_num * block_size) / float(total_size) * 100.0)) 
    	sys.stdout.flush() 
    filepath, _ = urllib.request.urlretrieve(DATA_URL, filename, _progress) 
    print()

    [参考1][参考2]


 

你可能感兴趣的:(其它)