Change the default python to Python3.8 on Ubuntu 20.04 fresh install
Just realized there is a specific package to resolve.
When got the fresh installed Ubuntu Focal Fossa server edition, you can use python3 but the default python has not set yet.
ubuntu@prime:~$ python
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
ubuntu@prime:~$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
Follow the official doc to update-alternatives
then got this:
ubuntu@prime:~$ sudo update-alternatives --set python /usr/bin/python3.8
update-alternatives: error: no alternatives for python
There are two methods to resolve:
Method 1:
ubuntu@prime:~$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
ubuntu@prime:~$ sudo update-alternatives --config python
There is only one alternative in link group python (providing /usr/bin/python): /usr/bin/python3
Nothing to configure.
Method 2: use the python-is-python3
package
ubuntu@prime:~$ sudo apt install -y python-is-python3
ubuntu@prime:~$ python -V
Python 3.8.10
Enjoy!