If you’re newbies in python world, and you want to know “How to install Python on Ubuntu?” This article is for you to understand how to install Python 3.6 or 3.8 on Ubuntu machines.
Python installation on Linux OS, will typically included as part of the distribution installation. That will require root access to the system. If you have any older version of Python on your Linux system, you can open a command prompt and run to check version.
$ python3 --version
If you have python installed on your system, will show response message like.
$ python3 --version Python 3.6.10
How many methods to Install Python on Ubuntu
There are two methods to install Python on Ubuntu.
- Package managers
- Source Code
Installation of Python on Ubuntu
So if you are using Ubuntu 16.10 or latest version, then try to execute the following command to install Python 3.6 :
$ sudo apt-get update $ sudo apt-get install python3.6
But if you have another version of Ubuntu like the latest LTS release or you want to install latest Python version (Python3.8), then try to use the deadsnakes PPA to install Python 3.8:
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update $ sudo apt-get install python3.8
Installation of Python on Redhat Linux
If you are using other Linux flavour, like RHEL8, then you can use following commands to install Python3.6:
$ sudo yum search python3.6 $ sudo yum install python3.6
Verify installation by typing following commands:
$ type -a python3 python3 is /usr/bin/python3 $ command -V python3 python3 is hashed (/usr/bin/python3) $ python3 --version Python 3.6.6
Working with Python 3
You may have Python 2.7 on your system available.
This command will launch the Python 2 interpreter. But if you want Python3, then.
This command will launch the Python 3 interpreter.
Set default version of Python on Redhat
If you install a multiple version of Python on system, you can set latest version as default to using following command:
$ sudo alternatives --set python /usr/bin/python3