Ubuntu has dropped Python 2 in 16.04. It is still installed after an upgrade, though (it was not part of the "obsolete packages").
Is there a clean way to remove Python 2 and all its dependencies in a clean way (to completely get rid of it)?
Is an apt purge the way to go?
root@ubuntu ~# apt purge python2.7 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libnss-ldap Use 'apt autoremove' to remove it. The following packages will be REMOVED: auth-client-config* ldap-auth-client* ldap-auth-config* libpam-ldap* libsmbclient* ndiff* python* python-bs4* python-chardet* python-crypto* python-dnspython* python-html5lib* python-ldb* python-lxml* python-ntdb* python-pkg-resources* python-samba* python-setuptools* python-six* python-talloc* python-tdb* python2.7* samba* samba-common-bin* samba-dsdb-modules* samba-libs* samba-vfs-modules* smbclient* winbind* 0 upgraded, 0 newly installed, 29 to remove and 0 not upgraded. After this operation, 58.4 MB disk space will be freed. 61 Answer
As there are still a lot of packages that depend on Python2 (like Samba and VirtualBox) you should have a close look at the packages that apt wants to remove before you let it proceed.
Use
sudo apt purge python2.7-minimal to completely remove Python2 and everything that depends on it.
8