升级TensorFlow时遇SSL错误求助(当前版本0.12.1)
Hey there, let's tackle that frustrating SSL error you're running into while trying to upgrade TensorFlow 0.12.1. That SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] message is a common issue with older Python 2.7 and pip setups—here's why it's happening and how to fix it:
What's Causing This?
PyPI stopped supporting older TLS protocols (TLSv1.0 and TLSv1.1) a while back, and the pip version bundled with your TensorFlow 0.12.1 environment is too old to communicate using the required modern TLSv1.2+ protocols. That's why you're getting the connection error.
Step-by-Step Fix
Upgrade pip to a compatible version for Python 2.7
Python 2.7 is end-of-life, but the last pip version that works with it and supports modern TLS is 20.3.4. Try running this first:pip install --upgrade pip==20.3.4If that still throws an SSL error (since your old pip can't connect to PyPI), use the official bootstrap script instead:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2.7Upgrade TensorFlow to the latest compatible version
TensorFlow dropped support for Python 2.7 after version 1.15, so that's the highest version you can install. Run this command once pip is updated:pip install --upgrade tensorflow==1.15
Your Error Reference
Here's the error traceback you shared:
Exception: Traceback (most recent call last): File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run wb.build(autobuilding=True) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/download.py", line 821, in unpack_url hashes=hashes) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/download.py", line 659, in unpack_http_url hashes) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/download.py", line 853, in _download_http_url stream=True, File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 488, in get return self.request('GET', url, **kwargs) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 475, in request resp = self.send(prep, **send_kwargs) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 596, in send r = adapter.send(request, **kwargs) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/Users/peymanghahremani/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 497, in send raise SSLError(e, request=request) SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
内容的提问来源于stack exchange,提问作者Peyman Ghahremani

