使用 pip install 的 SSLError(安装 tensorflow)

SSLError using pip install (to install tensorflow)

安装TF时出现异常:

File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/adapter.py", line 46, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/adapters.py", line 447, in send raise SSLError(e, request=request) SSLError: ("bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)",)

command: pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl

我不知道如何解决这个问题。我最近重装了pip,会不会是重装导致的?

我想你需要一些安全证书。

请尝试以下命令。

sudo pip install requests[security]

如果您收到任何错误消息,请卸载并重新安装 python-requests.

sudo pip uninstall requests
sudo apt-get install python-requests    

我希望它能为您提供所需的证书。 谢谢

SSL 错误肯定可以通过以下步骤解决。自己下载wheel然后pip install就可以了

# Ubuntu/Linux 64 位,仅 CPU:

$ wget https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

$ sudo pip install --upgrade tensorflow-0.5.0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64 位,启用 GPU:

$ wget https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

$ sudo pip install --upgrade tensorflow-0.5.0-cp27-none-linux_x86_64.whl

使用以下版本的certifi

pip2 install 'certifi==2015.4.28' --force-reinstall

之后将不会再有 SSL 错误。

在此处找到解决方案: https://github.com/kennethreitz/requests/issues/3212

我 运行 也遇到过这个问题,在我的情况下,使用 curl 手动下载并没有解决问题。 Curl 报告了这个:

curl: (60) SSL certificate problem: certificate is not yet valid

我的问题原来是 我的虚拟机时钟 没有 与互联网时间服务器同步 。重置我的 VM 时钟以使日期时间正确解决了这个问题,我能够直接从 pip 返回安装。

我已将此注释添加到 a related GitHub issue filed for TensorFlow. This Unix StackExchange question 最终让我找到了答案。

对于那些在终端上使用 macOS 运行 的人 window..

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

这个命令对我有用

pip3 install --trusted-host pypi.python.org  --upgrade http://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py3-none-any.whl

我将请求作为 http 而不是 https,我能够绕过 ssl 检查。希望这有帮助。

我使用 Anaconda 运行 "py -m pip install --upgrade tensorflow" 并且它有效。

尝试用另一个镜像升级你的pip版本。

pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/

如果您计算机上的日期有误,就会发生这种情况。用命令

检查
date

我是在设置为 8 月时收到的,但实际日期是 12 月。我用

更正了它
sudo date 12191148

12 月 19 日 11:48 但显然使用正确的日期。