Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiofortkamp/a9f85c7ff251ac88567daaf078d25628 to your computer and use it in GitHub Desktop.
Save fabiofortkamp/a9f85c7ff251ac88567daaf078d25628 to your computer and use it in GitHub Desktop.
install python 3.7.0 on RHEL/Centos 6.9

How to install Python 3.7.16 on CentOS 6.10

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.

Requirements

  • zlib 1.1.3 (better 1.1.4) or upper
  • openssl 1.1.0 or upper
  • Also, you will need libffi-devel rpm

Step 1: Set Environment

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

Building zlib 1.2.11

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

Building OpenSSL 1.1.0

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

Building Python 3.7.16

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.

Using Python 3.7.16

export LD_LIBRARY_PATH=${LOCAL}/openssl/lib:${LOCAL}/opt/lib
export PATH=${LOCAL}/python-3.7.16/bin:$PATH

Check version

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)]
 >>> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment