SSL module not available when installing python modules

309 Views Asked by At

I've been trying to install python modules from cmd, but I'm getting the following error:

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."))

If anyone could help that would be great!


Image of the error: error image

1

There are 1 best solutions below

0
On

I have the same problem on macOS. I guess my problem is because my python@2 was installed by homebrew.

Searched and tried many ways. Here is what works for me, and for your reference if you also happen to use homebrew on macOS.

I. Use default python on macOS

Step1. brew uninstall python@2

Step2. sudo /usr/bin/easy_install pip

Step3. cd HOMBREW_BIN_PATH

Step4. ln -sf /usr/bin/python python

Step5. ln -sf /usr/local/bin/pip pip

Then you can use pip as usual.

II. A workaround with non-https source instead

Refers to: https://blog.51cto.com/tenderrain/1956752

Suppose here we use non-https source of mirrors.aliyun.com, and want to install six

Method1. Directly by CLI

pip install -i http://mirrors.aliyun.com/pypi/simple six --trusted-host mirrors.aliyun.com

Method2. Create a ~/.pip/pip.conf

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

Then use pip install six as usual.