升级至pip9.0.3后仍遇TLSv1错误,Linux下无法安装软件包
Hey there, let's break down why you're hitting this TLSv1 error and how to fix it quickly.
The Root Cause
pip 9.0.3 is a very outdated version—PyPI stopped supporting TLSv1 and TLSv1.1 protocols years ago to enforce secure connections. Since this old pip release only knows how to use those deprecated protocols, it can't establish a valid SSL connection to PyPI anymore, which triggers the TLSV1_ALERT_PROTOCOL_VERSION error you're seeing.
Step-by-Step Solutions
Option 1: Install the Latest pip via get-pip.py (Most Reliable)
This is the surest way to get a modern pip version that supports TLS 1.2+:
- Grab the official get-pip.py script (you can retrieve it via Python's official resources; if direct downloads fail, transfer the file from a machine with a working pip setup if needed)
- Run it with your Python interpreter:
Or if you use Python 3 specifically:python get-pip.py
This will overwrite your old pip with the latest compatible version that works with PyPI's current security standards.python3 get-pip.py
Option 2: Force Upgrade with Trusted Host Flags (Emergency Workaround)
If you can't download get-pip.py right now, try forcing an upgrade using these flags to bypass temporary SSL check hurdles:
pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org
Note: This is a short-term fix—once you have the latest pip installed, you won't need these flags anymore for regular package installs.
After upgrading pip to a recent version (20.0+ at minimum), you'll be able to install packages from PyPI without running into this TLS error again.
内容的提问来源于stack exchange,提问作者redacted code

