- Use update-alternatives
- Change python command path
- Check python2 and python3 version
# Python2
> python --version
Python 2.7.17
# Python3
> python3 --version
Python 3.6.9- Check python command location
# Python2
> which python
/usr/bin/python
# Python3
> which python3
/usr/bin/python3- Python2
> sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1- Python3
> sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2Change default python
> sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.6 2 auto mode
1 /usr/bin/python2.7 1 manual mode
* 2 /usr/bin/python3.6 2 manual mode
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.6 2 auto mode
1 /usr/bin/python2.7 1 manual mode
* 2 /usr/bin/python3.6 2 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2Let me check default python
> python --version
Python 3.6.9