Search code examples
pythonsslpipopensslcentos

Problem installing packages using pip on CentOS (SSLError)


i am using centos 7.6.1810

i have downloaded these dependencies for python

yum install openssl-devel bzip2-devel libffi-devel
yum groupinstall "Development Tools"

I then download python3.10.9

sudo wget https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz

After unpacking I then try to do the install step

./configure --enable-optimizations
sudo make altinstall

The install step finishes suspiciously quickly, and when I try to use pip I get the following error

Package    Version
---------- -------
pip        22.3.1
setuptools 65.5.0
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
WARNING: There was an error checking the latest version of pip.

I thought this would be solved by downloading the openssl dependency

Does anyone know what my issue is or how i can troubleshoot?


Solution

  • If I follow the steps outlined in your question, then when building Python I see the error:

    Could not build the ssl module!
    Python requires a OpenSSL 1.1.1 or newer
    

    That's what I was suggesting in my comment. You will need to install a newer version of the openssl library in order to build Python with ssl support.

    Alternatively, you could consider running containerized Python using podman (or docker) to get a more recent version without needing to build anything.