ssl.SSLError: tlsv1 alert protocol version
I had the same error and google brought me to this question, so here is what I did, hoping that it helps others in a similar situation.
This is applicable for OS X.
Check in the Terminal which version of OpenSSL I had:
$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
>> OpenSSL 0.9.8zh 14 Jan 2016
As my version of OpenSSL was too old, the accepted answer did not work.
So I had to update OpenSSL. To do this, I updated Python to the latest version (from version 3.5 to version 3.6) with Homebrew, following some of the steps suggested here:
$ brew update
$ brew install openssl
$ brew install python3
Then I was having problems with the PATH and the version of python being used, so I just created a new virtualenv
making sure that the newest version of python was taken:
$ virtualenv webapp --python=python3.6
Issue solved.
Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]
Upgrade pip as follows:
curl https://bootstrap.pypa.io/get-pip.py | python
Note: You may need to use sudo python
above if not in a virtual environment.
(Note that upgrading pip
using pip
i.e pip install --upgrade pip
will also not upgrade it correctly. It's just a chicken-and-egg issue. pip
won't work unless using TLS >= 1.2.)
As mentioned in this detailed answer, this is due to the recent TLS deprecation for pip. Python.org sites have stopped support for TLS versions 1.0 and 1.1.
From the Python status page:
Completed - The rolling brownouts are finished, and TLSv1.0 and
TLSv1.1 have been disabled. Apr 11, 15:37 UTC
For PyCharm (virtualenv) users:
Run virtual environment with shell. (replace "./venv/bin/activate" to your own path)
source ./venv/bin/activate
Run upgrade
curl https://bootstrap.pypa.io/get-pip.py | python
Restart your PyCharm instance, and check your Python interpreter in Preference.
Related Topics
How Does Condensed Distance Matrix Work? (Pdist)
How to Set the Aspect Ratio in Matplotlib
Python Enum, When and Where to Use
Why Does Str(Float) Return More Digits in Python 3 Than Python 2
"Importerror: No Module Named" When Trying to Run Python Script
How to Convert CSV File to Multiline JSON
Valueerror: Could Not Convert String to Float: Id
How to Load a Module from Code in a String
Restart Cumsum and Get Index If Cumsum More Than Value
Pandas Dataframe Groupby Datetime Month
Python Os.Path.Join on Windows
Interactive Input/Output Using Python
Python Regex Match or Operator
How to Save an Image Locally Using Python Whose Url Address I Already Know
Split Text Lines in Scanned Document