# nltk ssl errors

# 错误信息 (nltk 3.5)

import nltk
 
nltk.download('punkt')    
 [nltk_data] Error loading Punkt: <urlopen error [SSL:
 [nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed
 [nltk_data]     (_ssl.c:590)>
False

# 修改

if __name__ == '__main__':
    import ssl
 
    try:
        _create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        pass
    else:
        ssl._create_default_https_context = _create_unverified_https_context
 
    import nltk
    nltk.download('punkt')
    print('end')

参考:

https://github.com/gunthercox/ChatterBot/issues/930#issuecomment-322111087
https://stackoverflow.com/questions/38916452/nltk-download-ssl-certificate-verify-failed

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

Jalen Chu 微信支付

微信支付

Jalen Chu 支付宝

支付宝

Jalen Chu 公众号

公众号