Objective
Python 3 comes pre-installed as a default python interpreter for Ubuntu 18.04 desktop and server.
However, on other minimal Ubuntu 18.04 installations, eg. docker, python is missing and needs to be installed manually. The following guide will provide you with information on how to install Python in Ubuntu 18.04 Bionic Beaver Linux.
Operating System and Software Versions
- Operating System: – Ubuntu 18.04 Bionic Beaver
Requirements
Privileged access to your Ubuntu System as root or via sudo
command is required.
Conventions
- # – requires given linux commands to be executed with root privileges either directly as a root user or by use of
sudo
command - $ – requires given linux commands to be executed as a regular non-privileged user
Other Versions of this Tutorial
Instructions
Install Python 3 on Ubuntu
To install Python 3 version on your Ubuntu system execute the following linux command. If the sudo
command is not available on your system and you are already logged in as a root
user, the sudo
command can be omitted:
$ sudo apt install python3-minimal
The above will provide you with a minimal installation of Python 3 interpreter. Check your Python version:
$ python3 -V Python 3.6.4+
Install Python 2 on Ubuntu
To install Python 2 version on Ubuntu 18.04 enter:
$ sudo apt install python-minimal
Check installed python version:
$ python --version Python 2.7.14+
Install Python modules
Many Python modules are already part of the Ubuntu repository. To search for Python modules enter:
$ apt search MODULE-NAME
To install any particular python module, first obtain the package name of the module you wish to install using the above command and then run the following linux command to install it:
$ sudo apt install MODULE-PACKAGE-NAME
Alternatively, visit the following page if you need to install PIP tool for managing Python packages.
{loadposition python-tutorial-toc}