1
我想通过URL下载数据集文件,但问题是我收到此消息。url lib错误python
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
Process finished with exit code 1
我不知道我做错了什么,因为我在线上学习一个教程。 这是我正在运行的文件,一切都很好,但问题是当它运行的URL下载。
print("download will complete at about 423 MB")
import sys
if sys.version_info[0] >= 3:
from urllib.request import urlretrieve
else:
from urllib import urlretrieve
url = "https://www.cs.cmu.edu/~./enron/enron_mail_20150507.tgz"
urlretrieve(url, filename="../enron_mail_20150507.tgz")
print("download complete!")
print()
print("unzipping Enron dataset (this may take a while)")
import tarfile
import os
os.chdir("..")
tfile = tarfile.open("enron_mail_20150507.tgz", "r:gz")
tfile.extractall(".")
检查这个问题一样:http://stackoverflow.com/questions/27835619/ssl-certificate-verify-failed-error – zwer
@zwer我检查那,但我不确定import ssl如何在这里工作,你能帮忙吗? –