December 28, 2018 in Tutorial2 minutes
In this tutorial we’ll learn how to install Python 2 on Ubuntu 16.04. Ubuntu 16.04 (Xenial Xerus) is not shipped with Python 2 by default but it’s available on Ubuntu 16.04 repository.
We can install python 2 from Ubuntu repository using command below:
$ sudo apt-get install python
As alternative you can also install package python-minimal
:
$ sudo apt-get install python-minimal
It will give output and question to continue the process. Enter Y.
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python2.7
python2.7-minimal
Suggested packages:
python-doc python-tk python2.7-doc binutils binfmt-support
The following NEW packages will be installed:
libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python
python-minimal python2.7 python2.7-minimal
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,877 kB of archives.
After this operation, 16.6 MB of additional disk space will be used.
Do you want to continue? [Y/n]
If you want to bypass confirmation above you can pass -y
option to apt-get
:
$ sudo apt-get install -y python
After installation is finished, you can run python
to verify:
$ python
It will open Python interactive shell:
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
To exit from Python interactive you can type CTRL + D
. You can also type exit()
or quit()
to exit.
To check python location you can use command below:
$ which python
/usr/bin/python
When we checked /usr/bin/python
, it’s actually a symbolic link to /usr/bin/python2.7
.
$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 Nov 24 2017 /usr/bin/python -> python2.7
In this tutorial we learned how to install Python 2 on Ubuntu 16.04 (Xenial Xerus). This is useful if we still have python app that is not compatible with Python 3 (yet) but we … [truncated]