TLSV1_ALERT_PROTOCOL_VERSION when trying to install python packages

If executing:
python setup.py install
give you error like:
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) -- Some packages may not be found!
it may be caused by outdate OpenSSL. But if after executing:
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
you see something like:
OpenSSL 1.0.2n 7 Dec 2017
then your SSL is pretty good. What to do then?

1. If you are in Virtual Env mode, deactivate it
2. Remove your Virtual Env
3. Run “brew update”
4. Run “brew install openssl” just in case
5. Run “brew install python3”

Next thing is check available python versions which you can use in venv:
ls /Library/Frameworks/Python.framework/Versions/
If you will see only “3.5”, go to python.org and download newest MacOs package (currently 3.6.5) then install as usual.
After installing make you that:
ls /Library/Frameworks/Python.framework/Versions/
will show:
3.5 3.6

Now you can create new Virtual Env with forced python 3.6:
virtualenv envname --python=python3.6

Now installing packages should work.

Leave a Reply