Home >Backend Development >Python Tutorial >How to Fix the PIP SSL Error: 'SSL: TLSV1_ALERT_PROTOCOL_VERSION'?

How to Fix the PIP SSL Error: 'SSL: TLSV1_ALERT_PROTOCOL_VERSION'?

DDD
DDDOriginal
2025-01-04 14:18:40460browse

How to Fix the PIP SSL Error:

PIP SSL Error: "SSL: TLSV1_ALERT_PROTOCOL_VERSION"

Problem:
When attempting to install Python packages using pip, an SSL error is encountered, particularly with the message "[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version."

Explanation:
This error stems from a TLS version deprecation for pip. Python.org sites no longer support TLS versions 1.0 and 1.1, leading to TLS protocol version mismatch errors.

Solution:
1. Upgrade Pip Externally:

Run the following command to upgrade pip using a direct download and installation method:

curl https://bootstrap.pypa.io/get-pip.py | python

Note: If using a virtual environment, you may need to prefix the command with sudo python.

2. Upgrade Pip in PyCharm (Virtualenv):

  • Activate the virtual environment in a shell:
source ./venv/bin/activate
  • Execute the upgrade command:
curl https://bootstrap.pypa.io/get-pip.py | python
  • Restart PyCharm and confirm the upgraded Python interpreter in Preferences.

After upgrading pip, it should resolve the TLS protocol version mismatch error and allow you to install Python packages successfully.

The above is the detailed content of How to Fix the PIP SSL Error: 'SSL: TLSV1_ALERT_PROTOCOL_VERSION'?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn