HowTo: Install Python On Linux

How do I install python an interactive high-level object-oriented language on Linux operating system?

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements Package manager
Time N/A
Python runs on many operating systems such as MS-Windows, Mac OS, Mac OS X, Linux, FreeBSD, OpenBSD, Solaris, AIX, and many varieties of free UNIX like systems. The easiest way to install the Python is to use package manger such as apt-get, yum, and so on.


A note about Debian / Ubuntu Linux user

Use the following command to search for available versions of Python under Debian and Ubuntu Linux:
$ apt-cache search python | egrep "^python2.[0-9] " --color
Type the following command to install python version 2.x:
$ sudo apt-get install python2.6
Type the following command to install python version 3.x:
$ sudo apt-get install python3.1
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
Suggested packages:
  python3.1-doc python3.1-profiler
The following NEW packages will be installed:
  python3.1 python3.1-minimal
0 upgraded, 2 newly installed, 0 to remove and 13 not upgraded.
Need to get 5,444 kB of archives.
After this operation, 19.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 squeeze/main python3.1-minimal amd64 3.1.3-1 [1,669 kB]
Get:2 squeeze/main python3.1 amd64 3.1.3-1 [3,775 kB]                                                                       
Fetched 5,444 kB in 27s (201 kB/s)                                                                                                                           
Selecting previously deselected package python3.1-minimal.
(Reading database ... 280220 files and directories currently installed.)
Unpacking python3.1-minimal (from .../python3.1-minimal_3.1.3-1_amd64.deb) ...
Selecting previously deselected package python3.1.
Unpacking python3.1 (from .../python3.1_3.1.3-1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for menu ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Setting up python3.1-minimal (3.1.3-1) ...
Setting up python3.1 (3.1.3-1) ...
Processing triggers for menu ...

A note about Red Hat/ RHEL / CentOS Linux user

Type the following command:
$ sudo yum install python
# yum install python

How do I find out installed python version?

Type the following command:
$ python --version
Sample outputs:

Python 2.6.6
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

2 comments… add one
  • YRS Sep 8, 2015 @ 6:33

    Thank You So much for article, it helped me .

  • george Jan 10, 2016 @ 11:45

    whay all linux users refers only to debian or ubuntu operating system? I use mageia or openSUSE. Nobody know how to use no matter programms on this?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.