Call + (44) 0843 289 4539

Configure Python 3.4 as default in Ubuntu 14.04

The Ubuntu operating systems from 14.X onwards all have python 3.x interpreter bundled , however python 2.7.6 interpreter is usually configured as the default interpreter. In this post we’ll provide details on how to configure python 3.x as the default interpreter.

To check if Python3 is installed on your release of simply open a terminal window and type python3 --version and you should see a response similar:

Install Python 3

If you do not have python3 installed then you can install it using:

sudo apt update
sudo apt install python3.6

Due to the way most Linux distributions are handling the Python 3 migration, Linux users using the system Python without creating a virtual environment first should replace the python command python3 and the pip command with pip3 –user.

For simplicity going forward we will install pip3

sudo apt install python3-pip



Configure python3 as default interpretter

To configure Python 3.4 as the default interpreter you need to configure an alias.

Create a bash_aliases file, that will be used by the terminal window in future. In your terminal window type in the following

gedit ~/.bash_aliases

This will open a text file for you to edit, in the text file type in

alias python=python3

Save and Exit the text file. Then type the following into the terminal window

source ~/.bash_aliases or you can simply close and re-open a terminal window

Now when you type python in your terminal window you should see

If you ever need to alter your your python version in future, you just need to edit your bash_aliases file again to point to python2 .

Configure pip3

You may also want to configure pip3 as your default package management system, in order to do so first ensure that is is installed

sudo apt install python3-pip

Then open the bash_aliases file again and add alias pip=pip3 so your file should look similar too

alias python=python3
alias pip=pip3

Refresh your source ~/.bash_aliases or you can simply close and re-open a terminal window. The you can test using pip --version

Video

Follow Me

Gary Woodfine

Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Follow Me
%d bloggers like this: