Ubuntu – How to remove Python 2 from Ubuntu 20.04

20.04pythonpython-2.7python3

I've upgraded recently from Ubuntu 18.04 to 20.04. But I can see that Python2 is still the default instead of python 3.8.2.

$ python -V

Python 2.7.18rc1

$ python3 -V

Python 3.8.2

Is it possible to remove python 2 and replace it with Python 3.8?

EDIT:
I have always used the following aliases in my ubuntu 18.04:

alias python='python3'
alias pip='pip3'

After upgrading, I removed those aliases because I thought python2 should no longer be there but it is still there.

Thanks

Best Answer

Before proceeding make sure that you do not really have packages which depend on Python 2.

Then you need to install special package which set aliases for you:

sudo apt-get install python-is-python3

And optionally remove all trails of Python 2 packages manually by

sudo apt-get autoremove --purge