Python is not installed by default on CentOS 8.
As you already know, there are two Python versions. Python 2 support ends in 2020. Python 3 is the present and future of the language.
Installing Python 3 on CentOS 8
dnf install python3
python3 --version
Python 3.6.8
Installing Python 2 on CentOS 8
The Python 2 packages are also included in the default CentOS 8 repositories.
To install Python 2, enter the following command:
sudo dnf install python2
Verify the installation by typing:
python2 --version
The output should look something like this:
Python 2.7.15
To execute Python 2, type python2, and to run pip type pip2.
Set Default Python Version (Unversioned Python Command)
If you have applications that expect to find the python command in the system’s path, you’ll need to create the unversioned python command and set the default version.
To set Python 3 as the system-wide unversioned python command, use the alternatives utility:
sudo alternatives --set python /usr/bin/python3
For Python 2, type:
sudo alternatives --set python /usr/bin/python2
The alternatives command creates a symlink python that points to the specified python version.
Type python --version in your terminal, and you should see the default Python version.
To change the default version, use one of the commands above. If you want to remove the unversioned python command, type:
sudo alternatives --auto python
No comments:
Post a Comment