
error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
python下载文件到指定目录报错。
·
python下载文件到指定目录报错
error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)>
如何解决?用如下的脚本代码:
- 链接要改成http开头的,不是https
- 添加
ssl._create_default_https_context = ssl._create_unverified_context - ProxyHandler要使用代理
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
proxy_handler = urllib.request.ProxyHandler({'http': os.environ['http_proxy'], 'https': os.environ['http_proxy']})
downloader = urllib.request.build_opener(proxy_handler)
urllib.request.install_opener(downloader)
DATA_UTILS_URL = "http://raw.githubusercontent.com/google-research/simclr/master/tf2/data_util.py"
urllib.request.urlretrieve(DATA_UTILS_URL, output_path)
更多推荐


所有评论(0)