How to install Python in Ubuntu and Linux Mint

Guide to install latest Python in Ubuntu and derivatives

install python in ubuntu

Python is one of the popular object-oriented programming languages used for developing many kinds of software. The biggest advantage of Python is its strong support for integration with other languages and tools, and the simplicity in which it can be learned in few days.

It can be installed on most of Operating systems including Linux, Windows, and Mac OSX. It is Free and Open Source Software (FOSS). This tutorial will help you in setting up and installing the latest version of Python on Ubuntu and its derivatives including Linux Mint and elementary OS.

Install Python in Ubuntu and Linux Mint

This tutorial is done on Ubuntu 16.04. It should work on Linux Mint 18.1 and above as well as elementary OS.

Ubuntu and Linux Mint come pre-installed with some version of Python. The only thing you need to verify is if it’s the latest version. To check the current version installed on your computer, launch ‘Terminal’ and type the following command:

python3 -V

You should see a lot of output in the terminal, but look of Python version_number followed by date. My Linux Mint PC gives says:

Python 3.5.2 (default, Nov 17 2016, 17:05:23)

But as of when this article was written, the Python version available at official website is Version 3.6.0. It’s always good idea to have the latest version to get maximum features.

The easiest way of installing Python in Ubuntu and its derivatives is by using apt-get command. Of course there is also a lengthy way to manually download and install it. We shall discuss both the methods here.

METHOD 1: Using apt-get command

STEP 1: Launch Terminal.

STEP 2: Copy and paste the following command and hit enter to add J Fernyhough’s PPA.

sudo add-apt-repository ppa:jonathonf/python-3.6

STEP 3: Update the sources.

sudo apt-get update

STEP 4: Finally install Python 3.6 using apt-get command. It will download the installer package and install it. You will have to enter root password when prompted.

sudo apt-get install python3.6

METHOD 2: Compile from Source Code

If you wish not to add any more PPAs into your computer, you can download the Python source code and compile it.

STEP 1: Before installing Python, it is recommended to install some dependencies. To do that, launch Terminal and copy-paste following commands in the terminal and hit enter.

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

STEP 2: Go to Download Python official webpage and download the latest version of Python. You can download the Gzipped source tarball.

STEP 3: Launch Terminal and navigate to the ‘Downloads’ folder or wherever you downloaded the Python .tgz package. Make sure to use the exact file name to extract after -xvf in the below command.

cd Downloads
tar -xvf Python-3.6.0.tgz

STEP 4: Now navigate into the extracted directory.

cd Python-3.6.0

STEP 5: You can now compile the source code. Enter following command one by one.

./configure
make
make install

Python should now be installed on your computer.

Hi there! I’m Kiran Kumar, founder of FOSSLinux.com. I’m an avid Linux lover, and enjoys hands-on with new promising distros. Currently, I’m using Linux Mint as a daily driver and run several other distros such as Fedora, Solus, Ubuntu, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities especially during Winter ;). When I’m not writing for FOSSLinux, I’m seen biking and hiking on scenic trails. Hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more, and spread my love for Linux. If you find time, drop me an email or feedback from ‘Contact’ page. Or simply leave a comment below if you found this article useful. Have a good day!

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz