Install Python 3.x from Source on CentOS or RHEL

From UVOO Wiki
Revision as of 21:31, 18 January 2020 by 172.16.0.159 (talk)
Jump to navigation Jump to search
<h1>!/bin/bash</h1>

<h1>This should work on CentOS 6 and greater</h1>

set -e
python_version=3.6.9

yum install -y gcc openssl-devel bzip2-devel libffi-devel curl tar
cd /usr/src
curl -O https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz
tar xzf Python-${python_version}.tgz
cd Python-${python_version}

<h1>./configure --enable-optimizations  # This takes longer to compile</h1>

./configure
make altinstall
rm /usr/src/Python-${python_version}.tgz
python3.8 -V

<h1>Using newer versions on CentOS 6</h1>

<h1>python_version=3.8.1  # ssl issue may have to use --with-openssl=/path/to/your/local/install</h1>

<h1>python_version=3.7.5  # ssl issue</h1>

<h1>https://help.dreamhost.com/hc/en-us/articles/360001435926-Installing-OpenSSL-locally-under-your-username</h1>