How to install Python 3 on CentOS, Ubuntu and Windows?
Python is an open, powerful, interpreted, and easy-to-learn programming language that supports multiple platforms. It is one of the most preferred programming languages in the field of data analysis and machine learning.
It offers an extensive set of built-in and portable libraries that can be easily included to extend your Python project. In addition, it has broad support for object-oriented and functional programming techniques of software development.
Python currently offers both Python 2.x and Python 3.x, which are not fully compatible with each other and have a few differences. Therefore, choosing to use any of them should be a planned decision based on your current environment and needs. Most Linux distributions come pre-installed with a version of Python due to its widespread use in OS libraries and software.
This article will cover installing Python 3 on CentOS, Ubuntu and Windows platforms. Python 3 can be installed along with Python 2, but you must be careful about specifying the system's default Python interpreter.
Python 3 on CentOS 6.x/7.x
For a distribution based on CentOS 6.x/7.x or RHEL, you can install Python 3 using yum.
$ sudo yum install python3
Confirm by pressing "y" when prompted:
Is this ok [y/d/N]: y
The Python 3 install log on CentOS 7 is below:
$ sudo yum install python3Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package python3.x86_64 0:3.6.8-18.el7 will be installed --> Processing Dependency: python3-libs(x86-64) = 3.6.8-18.el7 for package: python3-3.6.8-18.el7.x86_64 --> Processing Dependency: python3-setuptools for package: python3-3.6.8-18.el7.x86_64 --> Processing Dependency: python3-pip for package: python3-3.6.8-18.el7.x86_64 --> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-18.el7.x86_64 --> Running transaction check ---> Package python3-libs.x86_64 0:3.6.8-18.el7 will be installed --> Processing Dependency: libtirpc.so.1()(64bit) for package: python3-libs-3.6.8-18.el7.x86_64 ---> Package python3-pip.noarch 0:9.0.3-8.el7 will be installed ---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed --> Running transaction check ---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================== Package Arch Version Repository Size ========================================================================================================================================================================== Installing: python3 x86_64 3.6.8-18.el7 updates 70 k Installing for dependencies: libtirpc x86_64 0.2.4-0.16.el7 base 89 k python3-libs x86_64 3.6.8-18.el7 updates 6.9 M python3-pip noarch 9.0.3-8.el7 base 1.6 M python3-setuptools noarch 39.2.0-10.el7 base 629 k Transaction Summary ========================================================================================================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 9.3 M Installed size: 48 M Is this ok [y/d/N]: y Downloading packages: (1/5): python3-3.6.8-18.el7.x86_64.rpm | 70 kB 00:00:00 (2/5): libtirpc-0.2.4-0.16.el7.x86_64.rpm | 89 kB 00:00:00 (3/5): python3-setuptools-39.2.0-10.el7.noarch.rpm | 629 kB 00:00:01 (4/5): python3-pip-9.0.3-8.el7.noarch.rpm | 1.6 MB 00:00:06 (5/5): python3-libs-3.6.8-18.el7.x86_64.rpm | 6.9 MB 00:00:15 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 613 kB/s | 9.3 MB 00:00:15 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libtirpc-0.2.4-0.16.el7.x86_64 1/5 Installing : python3-setuptools-39.2.0-10.el7.noarch 2/5 Installing : python3-pip-9.0.3-8.el7.noarch 3/5 Installing : python3-3.6.8-18.el7.x86_64 4/5 Installing : python3-libs-3.6.8-18.el7.x86_64 5/5 Verifying : libtirpc-0.2.4-0.16.el7.x86_64 1/5 Verifying : python3-setuptools-39.2.0-10.el7.noarch 2/5 Verifying : python3-libs-3.6.8-18.el7.x86_64 3/5 Verifying : python3-3.6.8-18.el7.x86_64 4/5 Verifying : python3-pip-9.0.3-8.el7.noarch 5/5 Installed: python3.x86_64 0:3.6.8-18.el7 Dependency Installed: libtirpc.x86_64 0:0.2.4-0.16.el7 python3-libs.x86_64 0:3.6.8-18.el7 python3-pip.noarch 0:9.0.3-8.el7 python3-setuptools.noarch 0:39.2.0-10.el7 Complete! $
Python 3 on CentOS 8.x
Python 3 can be installed on CentOS 8.x using the DNF package manager. Use the command below to start installing Python 3:
$ sudo dnf install python3
Confirm by pressing "y" when prompted:
Is this ok [y/N]: y
A snippet of the Python 3 installation log on CentOS 8 is shown below:
$ sudo dnf install python3Last metadata expiration check: 6:25:17 ago on Friday 11 December 2020 12:44:46 PM IST. Package python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 is already installed. Dependencies resolved. ========================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================== Upgrading: python36 x86_64 3.6.8-2.module_el8.3.0+562+e162826a AppStream 19 k Transaction Summary ========================================================================================================================================================================== Upgrade 1 Package Total download size: 19 k Is this ok [y/N]: y Downloading Packages: python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64.rpm 5.6 kB/s | 19 kB 00:03 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 4.6 kB/s | 19 kB 00:04 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 1/2 Running scriptlet: python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 1/2 Cleanup : python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 2/2 Running scriptlet: python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 2/2 Verifying : python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 1/2 Verifying : python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 2/2 Installed products updated. Upgraded: python36-3.6.8-2.module_el8.3.0+562+e162826a.x86_64 Complete! $
On an Ubuntu/Debian OS, we can use apt or apt-get to get Python 3.
Newer Ubuntu systems already have Python 3 installed. If it was removed for some reason and you need to install it explicitly, use the following command:
$ sudo apt install python3
Check out Python 3 on Linux
Python 3 can be easily checked from the Linux terminal. To check the installed version, use:
$ python3 --versionPython 3.8.6 $
Python 3 в Windows
On Windows, Python 3 can be installed using a simple installation wizard from the official Python website. The default installer offered on the official download page should be sufficient for most purposes, unless you need to select a different version or architecture of Python.
The latest version available at the time of this writing is 3.9.1.
For a 64-bit architecture, the downloaded Python installer will be named something like this: python-3.xx-amd64.exe.
- Run the installer by running the downloaded .exe file.
- The default options selected for the installer should work. However, you have the option to change the installation location and components using the "Customize installation" option.
- There is also an option to install Python 3 for all users or just for your specific Windows user account.
- Finally, there is an option to add Python 3 to the Windows PATH environment variable, which will allow you to use Python 3 from the Windows command line from any directory.
- After confirming all settings, click "Install Now" to continue installing Python 3 with default options.
- The installation dialog will show the progress of the installation. Wait for completion.

- Once the installation is complete, you should be able to find the Python 3.x icon in the Windows start menu, which opens the Python 3 Interactive CLI.

- The Python 3 interactive command line interface allows you to write and execute Python commands interactively. For example, simple Hello World Python code can be written using the print command. Because it is an interactive command line interface, the command is interpreted at the same time and the output is immediately printed.

To practice writing code, you should get a Python IDE.
Further Reading
You can learn more about Python and its usage from the extensive documentation or online courses.