如何在16.04中删除Python 2?

Ubuntu在16.04中放弃了Python 2 。 它仍然在升级后安装(它不是“过时的软件包”的一部分)。

是否有一种干净的方式以干净的方式删除Python 2 及其所有依赖项 (以完全摆脱它)?

是一种apt purge方式吗?

 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. 

由于仍有很多依赖于Python2的软件包(如Samba和VirtualBox),因此在继续使用之前,您应该仔细查看apt要删除的软件包。

使用

 sudo apt purge python2.7-minimal 

完全删除Python2以及依赖它的所有东西。