Wednesday, October 23, 2019

Changing Python version in Ubuntu 16.04 LTS

problem statement
 Assume system has two version of pythion say v2.7 and v3.5 , and default pointing to v2.7
  and now , we need to make latest version as default

  step 1 :
     sudo update-alternatives --config python
     you will get below error if nothing is configured
     update-alternatives: error: no alternatives for python3
  step 2:
      sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
   Then run :
     sudo update-alternatives --config python
  step 3 : you can set python3.5 as default
       sudo update-alternatives  --set python /usr/bin/python3.5

now you can run $python --version