How to Install Python on Linux ?

There is a very good chance your Linux distribution has Python installed already, but it probably won’t be the latest version, and it may be Python 2 instead of Python 3.

How to Install Python 3 on CentOS

Prerequisites

  1. CentOS
  2. Login as an administrator on the terminal
  3. Yum must be configured on the system.

Installation
Installation includes following steps.

Install IUS community Repository
In order to install Python 3.6 on CentOS, we need to first install IUS community repository which provides extra packages for Enterprise Linux. Execute the following command to install IUS community repository.

$ sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm

CentOS How to Install Python 3 on CentOS

Install Python 3

Execute the following command to install python 3.6 on CentOS.

$ sudo yum install python36u

CentOS How to Install Python 3 on CentOS 1

Also Read :  How to install python on windows

Verify Python

To verify if we have installed correct version of python, we just need to type python3.6 -V on the terminal. The command will show the version installed which is 3.6.4 in my case.

CentOS How to Install Python 3 on CentOS 2

Working on Python’s script mode

Just type python3.6 on the terminal to enter the Python’s script mode. We can execute the python statements on this shell. Since, python 2 is by default installed on CentOS, hence typing python on the terminal takes us to the python2 shell, hence we have to type python3.6 to work on the desired python shell.

CentOS How to Install Python 3 on CentOS 3
Execute the valid python statements which get interpreted and show the desired output on the terminal as shown below.

CentOS How to Install Python 3 on CentOS 4
Hence, we have installed and get started with Python 3.

How to install Python on Ubuntu 16.04 LTS?

To install python3, just type the following command in the terminal and it will be installed automatically.

Python Installation

Update the APT Repository

$ apt-get update

Install Python

$ apt-get install python3.6

Verify Python

When we type python it shows default installed python that is 2.7.

$ python
Software Python 1

For Python3 type the following command, then it will show the other version as well.

$ python3
Software Python 2

Well, on the basis of these commands, we can test application for both Python versions.

Also Read How to Install python on Mac

openSUSE

We found several sites describing how to get zypper to install the latest version of Python, but they seemed problematic or outdated. We did not manage to get any of them to work successfully, so we fell back to building Python from source. To do that, you will need to install the development tools, which can be done in YaST (via the menus) or by using zypper:

$ sudu zypper install -t pattern devel_C_C++

Fedora

Fedora has a roadmap to switch to Python 3 as the default Python published here. It indicates that the current version and the next few versions will all ship with Python 2 as the default, but Python 3 will be installed. If the python3 installed on your version is not 3.6, you can use the following command to install it:

$ sudo dnf install python36

Discover more from mycodetips

Subscribe to get the latest posts sent to your email.

Discover more from mycodetips

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top