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 viasudo
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
Ubuntu 20.04 (Focal Fossa)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-minimalThe above will provide you with a minimal installation of Python 3 interpreter. Check your Python version:
$ python3 -V Python 3.6.4+
Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
Install Python 2 on Ubuntu
To install Python 2 version on Ubuntu 18.04 enter:$ sudo apt install python-minimalCheck 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-NAMETo 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-NAMEAlternatively, visit the following page if you need to install PIP tool for managing Python packages.
- Python Introduction and Installation Guide
- Python Files and the Interpreter
- Experimenting With Numbers and Text In Python
- Python Variables
- Working With Number Variables In Python
- Python String Basics
- Advanced Python Strings
- Python Comments
- Python Lists
- Python List Methods
- Python Multidimensional Lists
- Python Tuples
- Python Boolean Operators
- Python If Statements
- Python While Loops
- Python For Loops
- Python Dictionaries
- Python Advanced Dictionaries
- Python Functions