例如在 jupyter / colab / ipython 中运行一下命令,下载数据
!wget --no-check-certificate \
https://storage.googleapis.com/mledu-datasets/cats_and_dogs_filtered.zip \
-O /tmp/cats_and_dogs_filtered.zip
在PyCharm中如果运行一下命令:
import wget
url = "https://storage.googleapis.com/mledu-datasets/cats_and_dogs_filtered.zip"
output_filename = 'cats_and_dogs_filtered.zip'
# 下载到和.py同路径
wget.download(url, out=output_filename)
# 下载到其他路径
# out=路径+文件名
# out='./tmp/'+output_filename
会出现如下问题
……
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
解决方法:
方法一(已测):
加上这些代码即可
import ssl
import urllib
ssl._create_default_https_context = ssl._create_unverified_context
urllib.request.urlopen(url)
方法二:
终端中安装certifi
pip install --upgrade certifi
来源:https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3