1

I am on CentOS Linux release 7.9.2009 (Core), installed python3.10.12 from source using the following script

sudo yum update

sudo yum groupinstall "Development Tools"
sudo yum install zlib-devel bzip2-devel \
  openssl-devel ncurses-devel sqlite-devel \
  readline-devel tk-devel gdbm-devel \
  libffi-devel xz-devel


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


tar -xvf Python-3.10.12.tgz

./configure --enable-optimizations

make

sudo make altinstall


Python 3.10.12 (main, Jul  8 2023, 16:54:43) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information


sudo ln -s /usr/local/bin/python3.10 /usr/local/bin/python3

But, when trying pip, I got this error

There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/tutor/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

Tried to list the ssl modules installed for python3, and got this enter image description here

Also, when trying

python3.10 -m ssl

I got

ModuleNotFoundError: No module named '_ssl'

I found some answer that suggests adding --with-ssl option while building, and another answer that deosn't use this option at all. How can I solve this?

larsks
  • 277,717
  • 41
  • 399
  • 399
Fadwa
  • 1,717
  • 5
  • 26
  • 43
  • @larsks Thank you for your comment. I already installed it, you can find it in the third line of my installation script `sudo yum install zlib-devel bzip2-devel openssl-devel ..` – Fadwa Jul 09 '23 at 14:39
  • 1
    I've edited your question to make this list of packages easier to read without scrolling. – larsks Jul 09 '23 at 14:44

1 Answers1

2

If you look at your ./configure output, you will see:

checking for --with-openssl-rpath...
checking whether OpenSSL provides required APIs... no
checking for --with-ssl-default-suites... python

So the configure script is failing to detect necessary support in OpenSSL. If we look at config.log, we find:

configure:17849: checking whether OpenSSL provides required APIs
configure:17895: gcc -pthread -o conftest  -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden       conftest.c -lcrypt -lpthread -ldl  -lutil -lm -lssl -lcrypto   >&5
conftest.c:410:2: error: #error "OpenSSL >= 1.1.1 is required"
 #error "OpenSSL >= 1.1.1 is required"

And there's your problem; Python 3.10 requires OpenSSL version 1.1.1 or later, and CentOS 7 only provides 1.0.2.

If you want ssl support in your custom built Python, you'll need to first build a recent version of OpenSSL and install it somewhere on your system, and then provide configure with appropriate arguments to find it.


Alternately:

  • If you need Python 3.10 on CentOS 7, consider running running it in a container.

  • Consider installing a more recent operating system. CentOS 7 was originally released in 2014. That's almost 10 years ago. While it receives security updates, it doesn't receive feature updates, so it's simply not going to have recent versions of software.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • Thank you for your answer. How Can I get the output of `./configure` ? – Fadwa Jul 09 '23 at 16:52
  • I'm not sure I understand your question. When you run `./configure --enable-optimizations`, it produces lots of output. That's it. Look at it. – larsks Jul 09 '23 at 16:55
  • ah yes, will do. – Fadwa Jul 09 '23 at 16:59
  • This is a fantastic answer. Especially the final point regarding the age of CentOS 7. I used to be a Linux support engineer which mean supporting Suse SLES and Redhat RHEL (which is what CentOS is based on). They are very conservative distros that evolve slowly and are targeted at corporations which value stability. I'm always perplexed when I see someone being unhappy because installing the latest version of some app isn't as easy as it would be on any non-"enterprise" distro. – Kurtis Rader Jul 09 '23 at 18:25