It offers an extensive set of in-built and portable libraries that can be easily included to extend your Python project. Further, it has broad support for object-oriented and functional programming practices of software engineering. Python currently offers both Python 2.x and Python 3.x, which are not fully compatible with each other and have several differences. Hence the choice of using either of them should be a planned decision based on your current environment and needs. Most of the Linux distributions come pre-installed with some Python version due to its extensive use in OS libraries and software. This article will cover the installation of Python 3 on CentOS, Ubuntu, and Windows-based platforms. Python 3 can be installed along with Python 2, but you need to be careful in specifying the system’s default Python interpreter.
Python 3 on CentOS 6.x/7.x
For CentOS 6.x/7.x or RHEL based distribution, you can install Python 3 using yum. When prompted, please confirm by pressing ‘y’: Python 3 installation log on CentOS 7 is given below:
Python 3 on CentOS 8.x
Python 3 can be installed on CentOS 8.x using DNF package manager. Use the below command to start Python 3 install: When prompted, please confirm by pressing ‘y’: Log snippet of Python 3 install on CentOS 8 is shown below:
Python 3 on Ubuntu
On an OS running Ubuntu/Debian, we can use apt or apt-get to get Python 3. Newer Ubuntu systems already have Python 3 installed. In case it has been removed for some reason, and you need to install it explicitly, use the below command:
Verify Python 3 on Linux
Python 3 can be easily checked from Linux Terminal. To check the installed version, use:
Python 3 on Windows
On Windows, Python 3 can be installed with a simple wizard-based installer from the official Python site. The default installer offered on the official download page should be good enough for most purposes unless you need to choose a different Python version or architecture. The latest available version as of writing this article is 3.9.1.
For 64-bit architecture, your downloaded Python installer will be named something like python-3.x.x-amd64.exe.
Launch the installer by executing the downloaded exe file. Default options selected for the installer should be good to go. However, you have the option of modifying installation location and components with the Customize installation option. There’s also an option to install Python 3 for all users or just for your specific Windows user account. Finally, there’s an option to add Python 3 in the Windows PATH environment variable, which would allow you to use Python 3 from Windows Command Prompt from any directory location. Once all settings are confirmed, click Install Now to proceed with Python 3 installation using default options.
Installation dialog will show the installation progress. Please wait for it to complete.
On completion of the installation, you’ll be able to find Python 3.x icon in Windows’ Start Menu, which opens up Python 3 Interactive CLI.
Interactive Python 3 CLI allows you to write and execute Python commands interactively. As an example, a simple Hello World code in Python can be written using the print command. Since it is an interactive CLI, the command is interpreted simultaneously, and the output gets printed immediately.
To practice code, you should get Python IDE.
Further Reading
You can learn more about Python and its usage from its extensive documentation or by taking online courses. Next, find out how to install PIP to install Python packages.