The objective of this tutorial is to help you set up python 3.6 on Ubuntu. If you are on windows OS, you might want to check this other tutorial Python 3.6 download and install for windows.
Ubuntu 16.04 and Ubuntu 16.10 by default comes with two different versions of python installed, Python 2.7.12 and Python 3.5.2. At the time of this writing, the latest stable version of Python is 3.6, released on December 23rd, 2016. There are three different ways to install python 3.6 on Ubuntu:
- Installing python 3.6 on Ubuntu 16.10 and Ubuntu 17.04 from repository.
- Compile and install python 3.6 on Ubuntu 16.04.
- Install python 3.6 on Ubuntu 16.04 from PPA.
Before starting, check the default installed versions of python from the command line.
python --version python3 --version
You should see something like:
1. Installing python 3.6 on Ubuntu 16.10 and Ubuntu 17.04 from repository
If you are using Ubuntu 16.10 or Ubuntu 17.04, you can also install python 3.6 directly from repository. Python 3.6 is installed in the universe repository of Ubuntu 16.10 and Ubuntu 17.04, so you can install it with the commands below.
sudo apt update sudo apt install python3.6
Then check your version:
Note: This method only works on Ubuntu 16.10 and Ubuntu 17.04. It does not work on Ubuntu 16.04 as the universe repository of Ubuntu 16.04 does not have python 3.6 installed. If you tried the command on Ubuntu 16.04, you will probably see something like:
2. Compile and install python 3.6 on Ubuntu 16.04
First, we need to install some dependencies. We can do so by using the commands below:
sudo apt install build-essential checkinstall sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Next, extract the tarball.
tar xvf Python-3.6.0.tar.xz
Now cd into the source directory, configure the build environment and install.
cd Python-3.6.0/ ./configure sudo make altinstall
It might take some time for the
sudo make altinstall commands to run.
3. Install python 3.6 on Ubuntu 16.04 from PPA
You can install Python 3.6 from PPA using the commands below
sudo add-apt-repository ppa:jonathonf/python-3.6 sudo apt update sudo apt install python3.6
If Python 3.6 is correctly installed, you can use it by typing the following command:
You will see something like:
I hope this tutorial helped you install Python 3.6 on Ubuntu 16.04, Ubuntu 16.10 and Ubuntu 17.04.