In this topic, we described about the below sections -
Python is a cross-platform programming language that can run on multiple platforms like Windows, macOS, Linux, and can be ported to the Java and .NET virtual machines.
To install the python on the local machine, get the copy of the Python standard distribution software from the Python Software Foundation website at https://www.python.org/downloads based on your operating system, hardware (32-bit or 64-bit) and operating system version of your local machine.
As of writing the tutorial, the Python current version is 3.8.3. However, always check the latest version and install it.
Installation Procedure –
CentOS comes with Python 2.7.5 preinstalled and that is pretty much outdated. We need to update the Python to the latest version and below are the step by step procedure to install it –
- User should login as an Administrator.
- Yum must be configured on the system.
Step1 - Install required packages for Python
Use the following command to install Python prerequisites.
# sudo yum install gcc openssl-devel bzip2-devel libffi-devel
Step2 - Download Python 3.8.3
Download the Python from the official site using the below command.
# cd <target-download-library>
# wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
Next, extract the downloaded package.
# tar xzf Python-3.8.3.tgz
Step3 – Compile Python Source
Use below set of commands one by one to compile python source code on your system using altinstall.
# cd Python-3.8.3
# sudo ./configure --enable-optimizations
# sudo make altinstall
Now, remove downloaded source archive file from the system.
# sudo rm Python-3.8.3.tgz
Step4 – Verify the Python installation
In Python IDLE terminal, use print command to verify the python successfully installed or not. Here, we are using a print command to display the output.
$ print(“Welcome to TutorialsCampus”)
If the output gets displayed immediately and command prompt shows again, that confims the python installed successfully on the Centos. We can start coding of Python language.