I am trying to install a Python library using pip
, getting an SSL error:
~/projects/base pre-master± pip install xdict
Collecting xdict
Could not fetch URL https://pypi.python.org/simple/xdict/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement xdict (from versions: )
No matching distribution found for xdict
pip version: pip 9.0.1
How do I fix this error?
To upgrade the local version I used a slight variant:
This problem arises if you keep your pip and packages under your home directory as described in this gist.
And for Python 3 users, curl needs to be piped to
python3
:If any of the above
curl
commands fail with the same "tlsv1 alert protocol version" error, please ensure your system's underlying OpenSSL library is at least version 1.0.1, for TLS v1.2 to work.Both curl and pip (and wget) depend on OpenSSL for establishing SSL connections. The version can be verified with
$ openssl version
command.libcurl itself supports TLS 1.2 since curl version 7.34, but older versions should also be able to connect if you have OpenSSL version 1.0.2 (or later), which uses TLS 1.2 by default. If you are lacking tools such as curl and cannot install it, it is also possible to download get-pip.py (or the pip package itself) using your favourite web browser...
Finally, if still no-go, another thing that can help (especially for older OS/Python versions) is to ensure the following Python packages (dependencies related to SSL and pip functioning) are installed:
pyasn1, certifi, asn1crypto, cryptography, pyOpenSSL, urllib3
You can check which one is missing by trying this import in Python interpreter:
Because pip cannot connect (yet), just download their latest wheels from pypi.org via your favourite web browser one by one, and install using
pip install --user <package-file.whl>
command (orpip3
for Python 3) in the same order as listed above to resolve pip dependencies.Note: It should be preceded with a shell command
$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
(orpython3-dev
in case of Python 3) to ensure these Python packages can be built.I also hit this problem on my windows10 and tried all the answers but didn't solve my problem.
After that, I find the pip configuration file had been modified. So, I set the
pip.ini
as the original default configuration, re-run the pip command and it works for me!In summary of the situation of mine:
Check the pip.ini (usually under the path
C:\ProgramData\pip
) had been modified;If yes in step1, try to reset it to a default configuration.
I tried all existing fixes and not working for me
I re-install python 2.7 (will also install pip) by downloading .pkg at https://www.python.org/downloads/mac-osx/
works for me after installation downloaded pkg
Check your TLS version:
If your TLS version is less than 1.2 you have to upgrade it since the PyPI repository is on a brownout period of deprecating early TLS.
Source - Time To Upgrade Your Python: TLS v1.2 Will Soon Be Mandatory
You can upgrade the TLS version using the following command:
This should fix your problem. Good luck!
EDIT: You can download packages using your own private python package repository regardless of TLS version. Private Python Package Repository
This worked for me. Add sudo before python