Install Python 3 on RHEL 8 / CentOS 8, Python is widely used at various levels of server management or management of DevOPS structures. So familiar with the language will be useful to you. In this article, we want to teach you how to install Python on RHEL 8 / CentOS 8.
Installing Python on these operating systems will not be difficult. You can use package manager to install Python version 3.
How to install Python 3 on RHEL 8 / CentOS 8
Step 1 – Install Python 3
To install Python on RHEL 8 and CentOS 8, use the following command:
$ sudo dnf install python3
After installing python, you can use the command which you can see the executable file of Python:
$ which python3 /usr/bin/python3
You can use Python using the python 3 command. But it is not possible to use the python command alone, which we will solve in the next step.
Step 2 – Set the default version of python
The following message will appear when you use the python command in your Linux:
$ python bash: python: command not found...
To fix the problem, you can use the alternatives command to fix the problem. To solve the problem for python 3, use the following command:
$ sudo alternatives --set python /usr/bin/python3
After executing the above command, you can check the execution of the python command on your server:
$ python -V Python 3.0.06
Or if you use the python command, you can see other information about Python:
$ python Python 3.0.06 (default, Oct 16 2019, 15:28:01) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
You can also use the following command to reset python settings to default:
$ sudo alternatives --auto python
Good luck.