How do I install python 3.5.2? [duplicate]
Basic process:
sudo apt-get update
sudo apt-get install python3
If you want a very specific version:
sudo apt-cache show python3
sudo apt-get install python3=3.5.1*
As you must have already noticed that Ubuntu 16.04 has 'python 2.7.12' by default. To check the default python version, run below line
$ python -V
it should return 'Python 2.7.12'
It is recommended that we don't try to modify/uninstall this default package of python because there could be many other system files/applications depending on it, and it might create some unexpected errors or issues if we uninstall this default python package.
So, to use the latest version of python, it would be better to go for creating a virtual environment ('virtualenv'). This is a module inside python which facilitates us to use multiple python versions on the same system.
Step-1: First install python3 -
$ sudo apt-get update
$ sudo apt-get install python3
Step-2: Now install 'virtualenv'-
$ pip install virtualenv
Step-3: Now set the path of virtualenv to your desired directory. lets first create a desired directory-
$ mkdir MYENV
it will create a folder in the current directory with the name 'MYENV'
Step-4: set the path of virtualenv to the created(desired) directory-
$ sudo virtualenv -p python3 MYENV
Step-5: Activate the virtualenv
$ source MYENV/bin/activate
done.. you should be able to get (MYENV) as prefix in the terminal command line. Now run below command
$ python -V
it should return 'python 3.5.2'