Configure Python 3.4 as default in Ubuntu 14.04




The Ubuntu 14.04 LTS, Trusty Tahr, release has python 3.4 interpreter bundled , however python 2.7.6 interpreter is still the default interpreter if you access the REPL using the terminal window. In this post we will provide details on how to configure python 3.4 as the default on Ubuntu 14.04 when using the REPL in the terminal window.

Although python 3.4 is stable enough to use on Ubuntu 14.04 there are a few libraries that are not available at the time of writing (9 May 2014),  most notably is the ensurepip module , a number of linux distributions (fedora,  debian etc)  are also wrestling with support of pip and have also omitted support for the module at present.
The ensurepip module provides support for bootstrapping the pip installer into an existing python installation or virtual environment, realistically the majority of python developers could probably live without the support for this library for the time being.

It is possible to configure  Python 3.4 as default interpreter for the ubuntu 14.04, when using Python in the terminal window.  To configure Python 3.4 as the default interpreter you need to configure an alias, the following steps details this. a new alias for Python follow these steps:
Open the your Terminal window (Ctrl + Alt + T)
Type in  python





Exit the command line ([key]Ctrl[/key] + [key]D[/key])
We now need to create a bash_aliases file, that will be used by the terminal window in future. In your terminal window type in the following

sudo 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

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 .




Gary Woodfine

Technical Director at Denizon
Gary is Technical Director at Denizon, an independent software vendor specialising in IoT, Field Service and associated managed services,enabling customers to be efficient, productive, secure and scalable in a way which helps them address and reduce their ecological impact.

Denizon's product line successfully integrate IoT, Artificial Intelligence and Blockchain technology to enable efficient, productive, secure and scalable solutions to help organisations address increasing energy demands, ecological impact and Health & Safety concerns of their staff.

Latest posts by Gary Woodfine (see all)