27

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.
6
  • 2
    What exactly do you mean by "clean way"? Python2 is only installed if some of the packages need it. Removing it might break the system. Apr 23, 2016 at 9:36
  • @mikewhatever: I did an upgrade from 15.10 where Python 2 was needed by the system. Since 16.04 does not ship it at all it means it is not needed anymore. So removing Python 2 should not break the system - which is what I fear the most. As for extra software - it does not matter if they break (I will remove them as well in that case)
    – WoJ
    Apr 23, 2016 at 9:39
  • Well, good luck then. :~) Apr 23, 2016 at 9:46
  • 3
    However, many apps still need it. Maybe the update installed something requiring python2? I'd say don't remove it.
    – user423626
    Apr 23, 2016 at 9:58
  • @BharadwajRaju: wouldn't apt purge show me the dependencies? - and allow me to make up my mind (in my case samba would be a problematic package to remove for instance)
    – WoJ
    Apr 23, 2016 at 10:00

1 Answer 1

36

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
  • I just did it, and many things got uninstalled. So far the only I'm missing is "duplicity", so my deja-dup backup copies are now broken because deja-dup relies on duplicity. It seems there's still not a duplicity version that supports python 3, and they keep doing changes with python 2.7, so it's unlikely it's going to be one anywhere in the near future. It's somehow a shame because deja-dup is the default backup system in Ubuntu. May 13, 2017 at 14:35
  • JFTR, the pulseaudio-equalizer also seem to depend on Python2 still... May 14, 2017 at 10:09
  • Calibre ebook application also depends on python 2.7 May 16, 2017 at 7:42
  • 6
    You should never do this! I did it and now my system is all fucked up! Dec 27, 2017 at 12:24
  • 9
    I read the comment too late....
    – fabio.sang
    Apr 25, 2018 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .