I am trying to install a Python library using pip
, getting an SSL error:
~/projects/base pre-master± pip install xdict
Collecting xdict
Co
Check your TLS version:
python2 -c "import urllib2,json; print(json.loads(urllib2.urlopen('https://www.howsmyssl.com/a/check').read())['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:
sudo apt-get update && sudo apt-get install openssl libssl-dev
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
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
The answers of installing pip via:
curl https://bootstrap.pypa.io/get-pip.py |sudo python
or curl https://bootstrap.pypa.io/get-pip.py | python
did not work for me as I kept on getting the error:
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip
I had to install pip
manually via:
pip
distribution websitetar.gz
versioncd
into the directorypython setup.py install
To upgrade the local version I used a slight variant:
curl https://bootstrap.pypa.io/get-pip.py | python - --user
This problem arises if you keep your pip and packages under your home directory as described in this gist.
The following solution worked for me:
brew install python2
It also upgraded pip
to version 1.10.1