本文介绍了Tensorflow 中的 Python SSL 认证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试下载据称在以下位置处理的 MNIST 数据:

I'm trying to download the MNIST data which is supposedly handled in:

tensorflow.examples.tutorials.mnist.input_data.read_data_sets()

tensorflow.examples.tutorials.mnist.input_data.read_data_sets()

据我所知 read_data_sets 向服务器发送拉取请求以下载(大约)1.5GB 的数据.

As far as I'm aware read_data_sets sends a pull request to a server to download the (approx.) 1.5GB of data.

我不断收到此回溯错误:

I keep getting this traceback error:

文件"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",第 1318 行,在 do_open 中encode_chunked=req.has_header('Transfer-encoding')) 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",第 1239 行,请求self._send_request(method, url, body, headers, encode_chunked) 文件"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",第 1285 行,在 _send_request 中self.endheaders(body, encode_chunked=encode_chunked) 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",第 1234 行,在 endheaders 中self._send_output(message_body, encode_chunked=encode_chunked) 文件"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",第 1026 行,在 _send_output 中self.send(msg) 文件 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",第 964 行,发送self.connect() 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",第 1400 行,连接中server_hostname=server_hostname) 文件 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",第 401 行,在 wrap_socket 中_context=self, _session=session) 文件 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",第 808 行,在 init 中self.do_handshake() 文件 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",第 1061 行,在 do_handshake 中self._sslobj.do_handshake() 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",第 683 行,在 do_handshake 中self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:748)

这显然与 python 使用的 SSL 证书有关...所以我转到/Applications/Python 3.6/并执行位于那里的Install Certifactions.command"并收到此错误:

It obviously has something to do with the SSL cert python uses... so I went to /Applications/Python 3.6/ and executed the "Install Certifactions.command" located there and got this error:

回溯(最近一次调用):文件"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py",第 544 行,移动中os.rename(src, real_dst) PermissionError: [Errno 13] 权限被拒绝:'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2015.04.28.dist-info/DESCRIPTION.rst'-> '/var/folders/mq/g_jy_1qx1vjdb3xmdh7y62y80000gn/T/pip-3m8ixnf5-uninstall/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2028d.信息/描述.rst'

在处理上述异常的过程中,又发生了一个异常:

During handling of the above exception, another exception occurred:

回溯(最近一次调用):文件"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/basecommand.py",第 215 行,主要status = self.run(options, args) 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/commands/install.py",第 342 行,运行中prefix=options.prefix_path,文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_set.py",第 778 行,安装中required.uninstall(auto_confirm=True) 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_install.py",第 754 行,在卸载中path_to_remove.remove(auto_confirm) 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_uninstall.py",第 115 行,在删除重命名(路径,新路径)文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/utils/init.py",第 267 行,重命名Shutil.move(old, new) 文件/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py",第 559 行,移动中os.unlink(src) PermissionError: [Errno 13] 权限被拒绝: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2015.04.28.dist-info/DESCRIPTION.rst'

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_set.py", line 778, in install requirement.uninstall(auto_confirm=True) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_install.py", line 754, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/utils/init.py", line 267, in renames shutil.move(old, new) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py", line 559, in move os.unlink(src) PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi-2015.04.28.dist-info/DESCRIPTION.rst'

我的文件系统权限有问题吗?大约一个月前,我真的在这台计算机上重新安装了 OSX...

Is there something wrong with my filesystem permissions? I quite literally reinstalled OSX about a month ago on this computer...

有没有办法手动安装证书?或者发出 pull request 将数据下载到非 https 地址?

Is there a way I can manually install the certs? Or issue the pull request to download the data to a non-https address?

推荐答案

安装证书,或者双击 /Applications/Python 3.6/Install Certificates.command 中的文件(在 macOS 上),或者从 bash 终端运行此命令:

Install certificates, either double-clicking the file in /Applications/Python 3.6/Install Certificates.command (on macOS), or running this command from a bash terminal:

/Applications/Python\ 3.6/Install\ Certificates.command

现在安装了证书以通过 HTTPS 下载数据.

And now the certificates are installed to download the data over HTTPS.

来源:TensorFlow GitHub 上针对官方模型的专门问题.

这篇关于Tensorflow 中的 Python SSL 认证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:34