Ubuntu – Is it safe to remove python2 in ubuntu 18.04 LTS


I had Ubuntu 16.04 LTS for a long time because I was thinking to use Kail Linux, but I never got to installing it so I just got Ubuntu 18.04 LTS. Now I want to know if its safe to remove python2 because now I have python 3.6 and I when I code in python its still uses python2. And if it's not safe to remove python2 then is there a way to just make Visual Studio Code use python3.

Best Answer

See for yourself safely using apt's --simulate flag:

$ apt remove python --simulate

Read the proposed removals very carefully for applications and components that you don't want to remove.

If it turns out, after removing Py2, that you needed it after all...then it's trivial to reinstall.

WARNING: This answer applies only to Ubuntu 18.04 and newer. Earlier releases of Ubuntu have key components that depend upon Py2 (like apt). You may be very, very sorry if you remove Py2 in earlier releases of Ubuntu.