pip: Getting ssl certificate errors while using command pip3 install

Description

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 tried adding trusted host and the trusted host command but nothing seems to work for me on centos 7.9 also tried adding trusted host in pip.ini file tried with python 3.10 as well

Expected behavior

No response

pip version

pip-21.2.4

Python version

3.101.2 , 3.11

OS

centos 7.9

How to Reproduce

  1. install python on centos 7 using this link https://linuxstans.com/how-to-install-python-centos/
  2. then use command pip3.11 install unittest-xml-reporting
  3. it throws warnings and error
  4. anything with pip install is not working

Output

[root@localhost Documents]# python3.10 -m pip install -U pip
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (21.2.4)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
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
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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

Code of Conduct

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 23 (4 by maintainers)

Most upvoted comments

I met the same error, and resolved it by below steps:

  1. make sure openssl1.1.1 is installed:
sudo yum install -y openssl11 openssl11-devel
  1. export below options before run ./configure and make:
export CFLAGS="-I/usr/include/openssl11"
export LDFLAGS="-L/usr/lib64/openssl11"
  1. (OPTIONAL) export below option if you have multiple python versions installed, otherwise you might get: “Fatal Python error: init_import_site: Failed to import the site module” while running make:
export PYTHONPATH=/usr/local/lib/python3.11

NOTE1: /usr/local/lib/python3.11 doesn’t exist yet in such time. don’t worry about it. NOTE2: I’m compiling 3.11, so the folder name is /usr/local/lib/python3.11

  1. compile and install:
./configure --enable-optimizations
make
sudo make altinstall
  1. verify, it would output nothing and you should not see any error message:
python3.11 -c 'import ssl'

NOTE: change python3.11 to correct name

Hello, I have the same problem when trying to use pip, but in my case I don’t have the warning “WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.”. I have:

  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl
  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl
  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

I am using python 3.8 and if I try run python3.8 -c “import ssl” just works fine. What else could be this problem?

Getting below error for installing pip with 22.0.1 from python 3.9.

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==22.0.1 (from versions: none) ERROR: No matching distribution found for pip==22.0.1

Solution: pip requires OpenSSL to be installed on the machine. If it is not installed then we get the above error.

Try Installing OpenSSL 1.1.1g with below steps:

  1. Run wget with the URL to download the file. wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz

  2. Confirm the file’s integrity by downloading the SHA256 file on the same page next to it. wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz.sha256

  3. View the checksum to confirm the version you downloaded is safe to use. sha256sum openssl-1.1.1g.tar.gz ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46 openssl-1.1.1g.tar.gz cat openssl-1.1.1g.tar.gz.sha256 ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46 If they match, proceed with the next step.

  4. Decompress this file. tar zxvf openssl-1.1.1g.tar.gz

  5. Change into the new openssl directory cd openssl-1.1.1g

  6. Configure openssl: ./config --prefix=/home/username/openssl --openssldir=/home/username/openssl no-ssl2 provide your username in /home/username/openssl

  7. Run make. Once that is finished, run make test: make make test At the end, you should see All tests successful.

  8. Run make install make install

  9. Change back to your [home directory] cd ~

  10. Add the following lines to your .bash_profile.

export PATH=$HOME/openssl/bin:$PATH
export LD_LIBRARY_PATH=$HOME/openssl/lib
export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L /home/username/openssl/lib -Wl,-rpath,/home/username/openssl/lib"

In the last line, make sure to change username to your [Shell user].

  1. Update the .bash_profile. . ~/.bash_profile

  2. Test to confirm it’s installed in the correct location and that the version is 1.1.1. which openssl /home/username/openssl/bin/openssl openssl version OpenSSL 1.1.1g 21 Apr 2020

  3. Then try installing pip using below command python -m pip install -U pip

The following solved the problem on my Mac: brew install openssl@1.1

Had this same problem, after updating my system (Manjaro linux). Before that I had no such issue. I already had openssl 3.0.7 butI had to also install the openssl-1.1 package to get it working again

Turn off VPN is work

Had this same problem, after updating my system (Manjaro linux). Before that I had no such issue. I already had openssl 3.0.7 butI had to also install the openssl-1.1 package to get it working again

Thanks! That solved the issue for me. Also running Manjaro.