In this tutorial we will install Python 3.6, 3.7, 3.8 & 3.9 on CentOS 7. The default python version in CentOS 7 is 2.7.5. If we forcefully upgrade or replace this version, yum and other utitiles may break causing the OS to become unstable.
Instead of upgrading/replacing default python, we will install the new version of python using alternate install method. This setup will also install corresponding pip for each python version separately.
Install below pre-requisites:
1
sudo yum -y install wget make gcc openssl-devel bzip2-devel
Copy
Download python setup in tmp
location
1
2
cd /tmp/
wget https://www.python.org/ftp/python/3.6.12/Python-3.6.12.tgz
Copy
1
2
3
4
5
6
7
8
tar xzf Python-3.6.12.tgz
cd Python-3.6.12
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.6 /usr/bin/python3.6
sudo ln -sfn /usr/local/bin/pip3.6 /usr/bin/pip3.6
Copy
1
2
3
4
5
6
7
python3.6 -V
Python 3.6.12
pip3.6 -V
pip 18.1 from /usr/local/lib/python3.6/site-packages/pip ( python 3.6)
Copy
Install below pre-requisites:
1
sudo yum -y install wget make gcc openssl-devel bzip2-devel
Copy
Download python setup in tmp
location
1
2
cd /tmp/
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
Copy
1
2
3
4
5
6
7
tar xzf Python-3.7.9.tgz
cd Python-3.7.9
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.7 /usr/bin/python3.7
sudo ln -sfn /usr/local/bin/pip3.7 /usr/bin/pip3.7
Copy
1
2
3
4
5
python3.7 -V
Python 3.7.9
pip3.7 -V
pip 20.1.1 from /usr/local/lib/python3.7/site-packages/pip ( python 3.7)
Copy
Install below pre-requisites:
1
sudo yum -y install wget make gcc openssl-devel bzip2-devel
Copy
Download python setup in tmp
location
1
2
cd /tmp/
wget https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tgz
Copy
1
2
3
4
5
6
7
8
tar xzf Python-3.8.7.tgz
cd Python-3.8.7
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.8 /usr/bin/python3.8
sudo ln -sfn /usr/local/bin/pip3.8 /usr/bin/pip3.8
Copy
1
2
3
4
5
python3.8 -V
Python 3.8.7
pip3.8 -V
pip 20.2.3 from /usr/local/lib/python3.8/site-packages/pip ( python 3.8)
Copy
Install below pre-requisites:
1
sudo yum -y install wget make gcc openssl-devel bzip2-devel
Copy
Download python setup in tmp
location
1
2
cd /tmp/
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
Copy
1
2
3
4
5
6
7
8
tar xzf Python-3.9.1.tgz
cd Python-3.9.1
./configure --enable-optimizations
sudo make altinstall
sudo ln -sfn /usr/local/bin/python3.9 /usr/bin/python3.9
sudo ln -sfn /usr/local/bin/pip3.9 /usr/bin/pip3.9
Copy
python3.9 -V
Python 3.9.1
pip3.9 -V
pip 20.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9
Copy