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

How to Fix the 'SSL: TLSV1_ALERT_PROTOCOL_VERSION' Error When Installing Python Packages?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-08 08:06:15590browse

How to Fix the

Fix for "Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]" Error

When encountering the "SSL: TLSV1_ALERT_PROTOCOL_VERSION" error while installing Python packages using pip, the issue stems from outdated TLS protocols in pip. To resolve this problem, upgrade pip to the latest version.

Upgrade Procedure:

  1. Run the following command to upgrade pip:

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

    Note: Sudo may be required if you are not in a virtual environment.

  2. If you encounter a鸡-and-egg issue, use the following workaround:

    pip install --no-cache-dir --upgrade pip

Reason for Issue:

This error occurs because Python.org sites have discontinued support for TLS versions 1.0 and 1.1. TLS 1.2 or higher is now mandatory. Pip has recently implemented this change, which has resulted in the error.

For PyCharm (Virtualenv) Users:

  1. Activate your virtual environment:

    source ./venv/bin/activate
  2. Upgrade pip:

    curl https://bootstrap.pypa.io/get-pip.py | python
  3. Restart PyCharm and verify the Python interpreter in Preferences.

The above is the detailed content of How to Fix the 'SSL: TLSV1_ALERT_PROTOCOL_VERSION' Error When Installing Python Packages?. 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