This is an introduction to building and installing Python 3.7.16 from source on Centos 6.10. Unfortunately python 3.7.16 requires specifics version of openssl and Centos 6.10 does not provides these versions: So previous to configure python, you have to configure zlib and then openssl.
- zlib 1.1.3 (better 1.1.4) or upper
- openssl 1.1.0 or upper
- Also, you will need libffi-devel rpm
PYTHON_VERSION=3.7.16
export PYTHON_URL=https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
mkdir $HOME/opt
export LOCAL=$HOME/opt
mkdir $HOME/tmp
export DL=$HOME/tmp
yum install libffi-devel
cd ${DL}
wget -c https://zlib.net/zlib-1.2.13.tar.gz
tar xzvf zlib-1.2.13.tar.gz
cd zlib-1.2.13
./configure --prefix=${LOCAL}
make
make install
cd ${DL}
wget -c https://www.openssl.org/source/openssl-1.1.1t.tar.gz
tar xzvf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t
./config --prefix=${LOCAL}/openssl \
--openssldir=${LOCAL}/openssl \
--with-zlib-include=${LOCAL}/lib
export LD_LIBRARY_PATH=${LOCAL}/lib
make
make test TESTS=01-test_sanity V=1
make install
cd ${DL}
wget -c ${PYTHON_URL}
tar xzvf Python-${PYTHON_VERSION}.tgz
cd Python-${PYTHON_VERSION}
./configure --enable-optimizations \
--with-openssl=${LOCAL}/openssl \
--with-ssl-default-suites=openssl \
--prefix=${LOCAL}/python-${PYTHON_VERSION}
export LD_LIBRARY_PATH=${LOCAL}/openssl/lib:$LD_LIBRARY_PATH
make
make test <optional>
make altinstall
It is critical that you use make altinstall when you install your custom version of Python. If you use the normal make install you will end up with two different versions of Python in the filesystem both named python. This can lead to problems that are very hard to diagnose.
export LD_LIBRARY_PATH=${LOCAL}/openssl/lib:${LOCAL}/opt/lib
export PATH=${LOCAL}/python-3.7.16/bin:$PATH
python3.7 -V
Python 3.7.16
python3.7
>>> import sys
>>> print(sys.version)
3.7.0 (default, Aug 24 2018, 12:03:48)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
>>>