How to install Python in Ubuntu and Linux Mint

Guide to install latest Python in Ubuntu and derivatives

Python is one of the popular object-oriented programming languages used for developing many kinds of software. In today’s article, we will install Python on Ubuntu.

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 a few days.

It can be installed on most 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 on 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 the 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 the official website is Version 3.6.0. It’s always a 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 long 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 the 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 the following command one by one.

./configure
make
make install

Python should now be installed on your computer.

Kiran Kumar
Hi there! I'm Kiran Kumar, founder of FOSSLinux.com. I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, 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 Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day!

3 COMMENTS

  1. Hi Kiran,
    I’m not able to install python3.6 in linuxmint as i’m getting failures like E: Some index files failed to download. They have been ignored, or old ones used instead.I tried below steps also
    mint@mint ~ $ sudo cp /etc/apt/sources.list ~/
    mint@mint ~ $ sudo apt-get update
    but results were same,not able to install python3.6 on linuxmint 14.04.
    Could you please suggest to complete installation?
    Thanks in advance.

  2. Thanks Kiran,

    Python 3.7.4 is installed on Linuxmint 19 with your guidance.

    I got the following error after “make install”:
    ——ModuleNotFoundError: No module named ‘_ctypes’——

    Visited, https://github.com/pyenv/pyenv/issues/1183 and installation succeeded after running: sudo apt-get install libffi-dev

    Thanks a lot
    Nishant

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

24,262FansLike
192FollowersFollow

LATEST ARTICLES

How to create an Arch Linux Live USB drive on Ubuntu

create Arch Linux Live USB drive
This article provides a step-by-step guide on creating an Arch Linux USB installation media on Ubuntu PC. The Live USB media can be used to install Arch Linux.
manjaro complete usb drive
In this tutorial, we will show step by step how to install a Manjaro on a USB flash. For those new to this distro, it is a light-weight distro that is based on Arch Linux. Arch Linux is known for its simplistic approach and is typically made for Linux pros, but Manjaro bridges the gap between user-friendliness and rock-solid performance.
cool and fun linux commands
The real purpose of this article is to help Linux newbies get comfortable and confident with the Linux command-line.  While knowledge and comfort of the Linux GUI allow great power, it is the mastery of the command line, or CLI, affords the Linux user unlimited power and certifies them as a Linux power user well on their way to becoming an expert.
Uninstall Programs in Ubuntu
Uninstallation of programs can be done by graphical way using the Ubuntu Software Center, and the Synaptic Package manager. Command-line way of doing it is also possible using apt-get and aptitude commands. We shall discuss each one of them in detail.