解决PyCharm中用wget下载出现CERTIFICATE_VERIFY_FAILED问题

例如在 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: 

 解决方法:

方法一(已测):

加上这些代码即可

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

urllib.request.urlopen(urllink)

方法二:

终端中安装certifi

pip install --upgrade certifi

来源:https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3

你可能感兴趣的:(TensorFlow,python,wget,python)