Python marked as one of the most popular languages by a survey from stackoverflow . Python has a huge base of open source community and is being used in most in top Tech companies. It is widely used language for very heavy computation tasks like machine learning and AI it is the most favourite language to be used for this kind of heavy operational tasks that requires use computing power.
As you know there are two different Python versions python2 and python3. It has lot of improvements and security updates it includes multiple models improve the existing models and many other such features as been introduced by Python in Python 3.
This article will help you to install Python 3.9 on CentOs8 and RHEL based UNIX operating systems. To know more about this version visit Python official website .
Python 3.9.0 is the latest release of the Python with lot of features and performance optimizations .
A CentOS/RHEL 8 production server or a Linux VPS . Make sure you have GCC, make, and git installed on your VPS/Server .
4bits$ sudo yum install wget gcc openssl-devel libffi-devel bzip2-devel
Have a look at the article if you want to learn about Nginx servers .
- Install NVM on Centos8
- Instal JDK on Rocky Linux 8
- Install and Configure Nginx On Rocky Linux 8
- Grep Command Examples You dont Know
- Shell Script to Parse CSV Files Linux
In order to install python 3.9 , Execute the following command below .
4bits$ yum install python3
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Total download size: 9.3 M Installed size: 48 M
In order to verify if python 3.9 is installed properly or not you can execute the following command .
This will return output as
4bits$ Python 3.9.0 (default, Jun 7 2021, 17:28:10)
Now this was a pretty basic installation of python , Most of the time we want to install python from source . Now we will have a look at how we can install Python from source
We are going to install python from source . Now the reason to build it from source is many times we need to have a specific python version .Hence we need to get that specific version and install it in our systems.
4bits$ wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
Extract the downloaded tar file
tar xvf Python-3.9.6.tgz
Move to the folder and execute following command , below command will configure your python build for your env specific .
cd Python-3.9.6 4bits$ ./configure --enable-optimizations
Now , lets build the python source using
make utility .
4bits$ sudo yum make altinstall
IN order to verify installation execute following command , your installation should return the latest python version that you have installed just now.
4bits$ python3.9 --version
4bits$ Python 3.9.6
No this install the PIP as well lets verify the PIP version now
4bits$ pip3.9 --version
So one of the best practices to run any Python based application is create a separate virtual environment for each of your application to manage its own dependencies. Each application will have an isolated environment where applications Python project have its own module and set of dependencies let's have a look how we can create application specific virtual environment in your python .
4bits$ sudo /usr/local/bin/python3.9 -m project1 /home/4bits/python-app/project1
Now once your environment has been created you need to activate the environment so that it can manage its own dependencies within that folder
4bits$ source /home/4bits/python-app/project1/bin/activate
Now once you finish your task you can't activate the environment
In this tutorial we have seen how you can install python3 specifically on centos 8 or RHEL based Operating system .