How to Install Python 2.7.18 on CentOS/RHEL 7/6 and Fedora 32/31
Abstract: which we can’t remove as other applications depend on it. This tutorial will help you to install Python 2.7.18 without removing older versions. 1. Pre
Today, I was trying to install an application on my CentOS 7.4 system which required Python >= 2.7.10, but there are Python 2.7.5 installed, which we can’t remove as other applications depend on it. This tutorial will help you to install Python 2.7.18 without removing older versions.
1. PrerequisitesFirstly make sure that you have GCC package installed on your system. Use the following command to install GCC if you don’t have it installed.
yum install gcc openssl-devel bzip2-devel # On CentOS systems dnf install gcc openssl-devel bzip2-devel # On Fedora systems2. Download Python 2.7
Download Python using following command from python official site. You can also download the latest version in place of specified below.
cd /usr/src wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
Extract downloaded archive using tar command.
tar xzf Python-2.7.18.tgz3. Install Python 2.7
Now run the following commands to compile Python 2.7 and install on your system using altinstall
.
cd Python-2.7.18 ./configure --enable-optimizations make altinstall
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
Check the latest version installed of python using below command. During this installation, the latest Python binary was installed on path /usr/local/bin/python2.7. The existing binary was located under /usr/bin.
/usr/local/bin/python2.7 -V Python 2.7.18
Warning: Do not overwrite or link the original Python binary, This may damage your system.
5. Install PIPPIP is a useful utility to install and manage Python modules. Let’s install the PIP for the installed Python version.
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" python2.7 get-pip.py