Is it safe to remove Python 2.7.15rc1 from Ubuntu 18.04?

I upgraded my laptop from Ubuntu 16.04 to Ubuntu 18.04 as soon as I got it and I am not using Python 2.

Is it safe for me to remove it?

My terminal is showing the default version as Python 3.7.3.


Solution 1:

Run

apt purge -s python2.7

where -s is a simulation of what would happen.

and see for yourself what else you will lose.

On my system, Kubuntu 18.04, here's what I see:

The following packages were automatically installed and are no longer required:
  gir1.2-appindicator3-0.1 gir1.2-gtk-vnc-2.0 gir1.2-keybinder-3.0 gir1.2-libosinfo-1.0 gir1.2-libvirt-glib-1.0 gir1.2-spiceclientglib-2.0
  gir1.2-spiceclientgtk-3.0 gir1.2-vte-2.91 libgovirt-common libgovirt2 libgtk-vnc-2.0-0 libgvnc-1.0-0 libkeybinder-3.0-0 libphodav-2.0-0
  libphodav-2.0-common libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libusbredirhost1 libvirt-glib-1.0-0 spice-client-glib-usb-acl-helper
  syslinux-common virt-viewer xsltproc
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  boot-repair* boot-sav* boot-sav-extra* glade2script* kubuntu-settings-desktop* python* python-asn1crypto* python-cairo* python-certifi*
  python-cffi-backend* python-chardet* python-cryptography* python-dbus* python-enchant* python-enum34* python-gi* python-gi-cairo*
  python-gobject* python-gobject-2* python-gtk2* python-gtkspellcheck* python-idna* python-ipaddr* python-ipaddress* python-libvirt*
  python-libxml2* python-libxslt1* python-mutagen* python-openssl* python-pkg-resources* python-psutil* python-qt4-dbus* python-requests*
  python-six* python-urllib3* python-xdg* python2.7* ranger* recoll* terminator* trash-cli* virt-manager* virtinst* zim*
0 upgraded, 0 newly installed, 44 to remove and 0 not upgraded.

 

I won't be removing python2.7.


Looking further into this, one can find out what is present in a clean installation of Ubuntu 18.04, as opposed to an upgrade from an earlier version, by looking at /var/log/installer/initial-status.gz. I have such a system.

From a terminal window, run:

$ zgrep "Package: python2.7" /var/log/installer/initial-status.gz

The search will be empty indicating that no package containing the string python2.7 was installed.


In your case, since you upgraded from 16.04 to 18.04:

  • If you do have python-2-7-15rc1 on your system, it means it was retained from your previous system as part of the upgrade or that you subsequently installed software that depended on it.

  • Either way, removing such a package in 18.04 is safe with the caveat that programs depending on it that you installed (a) when using the previous system (before the upgrade) or (b) after the upgrade maybe removed.

  • Keep in mind that during the life of 18.04, if you install something like calibre or gimp or variety or virt-manager, doing so will bring python2.7 back.