Building Python 3.7.1 – SSL module failed

I solved it after 3 days only because of this blog. with python 3.7.4 openssl 1.1.0 centOS 6.

here is the summary :

First, some prerequisites:

sudo apt-get install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

use yum instead of apt-get if using centos linux.

Install ssl 1.0.2 or higher.

    cd /usr/src
    curl https://www.openssl.org/source/openssl-1.0.2o.tar.gz | tar xz
    cd openssl-1.0.2o
    ./config shared --prefix=/usr/local/
    sudo make
    sudo make install

We will need to pass /usr/src/openssl-1.0.2o into the Python configure script.

mkdir lib
cp ./*.{so,so.1.0.0,a,pc} ./lib

Now proceed with installing Python:

    cd /usr/src
    sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
    sudo tar xzf Python-3.7.0.tgz
    cd Python-3.7.0
    ./configure --with-openssl=/usr/src/openssl-1.0.2o --enable-optimizations
    sudo make
    sudo make altinstall

To test it out, run python3.7 and input:

import ssl
ssl.OPENSSL_VERSION

Hope it helps!

Leave a Comment