Setup Python3 as default Python version in Unix/Linux - Python for Data Analytics

Python Programs | Python Tricks | Solution for problems | Data Cleaning | Data Science

Setup Python3 as default Python version in Unix/Linux

On my Ubuntu machine, there are two versions of python available, python2.7 as default python version and python3. In this step, we will change the default python version to python 3.

Check the python version:

 python  

Result:

 Python 2.7.12 (default, Jul 1 2016, 15:12:24)  
 [GCC 5.4.0 20160609] on linux2  
 Type "help", "copyright", "credits" or "license" for more information.  
 >>>  

So the default python is 2.7 at the moment. Next, remove default python 2 and change the default to python 3 with the 'update-alternatives' command:

update-alternatives --remove python /usr/bin/python2
update-alternatives --install /usr/bin/python python /usr/bin/python3

Now check again the python version:

 python  

Result:
  
Python 3.5.2 (default, Jul  5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Configure default python on Ubuntu to python 3

1 comment: