0

Context

I'm using Ubuntu 20.04.2 LTS.
Before running the command I had several python version:

  • python2.7.18 (python)
  • python3.6 (python3)
  • python3.7.4 (python3.7)
  • python3.8.0 (python3.8)

Problem

I wanted to remove python3.8.0, so I ran $ sudo apt remove python3.8 (output below), and now I still have every python version except that python3 point now to python3.8.8. And I lost the GUI, I now use tty to access the terminal. It seems that I have important dependecies problems as I'm unable to reinstall gnome or ubuntu-desktop. I tried some answers of similar questions but none of them worked (listed below).

Complete tracebacks

As the outputs of the commands I tried are too long I can't post them with the question, so I created a github repo with complete traceback of every tried command.

Output

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  accountsservice-ubuntu-schemas dctrl-tools docbook-xml docutils-common fprintd gir1.2-appindicator3-0.1
  gir1.2-graphene-1.0 gir1.2-gtksource-4 gir1.2-ibus-1.0 gir1.2-mutter-6 gnome-panel-data gnome-screensaver ibus-data
  indicator-appmenu indicator-datetime indicator-keyboard indicator-messages indicator-power indicator-printers
  indicator-session indicator-sound jayatana libaccounts-glib0 libamtk-5-0 libamtk-5-common libbamf3-2 libfcitx-gclient1
  libfcitx-utils0 libfprint-2-2 libgnome-panel0 libgsound0 libgupnp-av-1.0-2 libgupnp-dlna-2.0-3 libimagequant0
  liblightdm-gobject-1-0 libnetplan0 libpam-fprintd librsync2 librygel-core-2.6-2 librygel-db-2.6-2 librygel-renderer-2.6-2
  librygel-server-2.6-2 libsdl2-image-2.0-0 libtepl-4-0 libunity-gtk2-parser0 libunity-gtk3-parser0 liburl-dispatcher1
  libxcb-xtest0 linux-headers-5.3.0-62 linux-headers-5.3.0-62-generic python-pip-whl rygel sgml-base sgml-data
  switcheroo-control ubuntu-touch-sounds unity-gtk-module-common unity-gtk2-module unity-gtk3-module
  unity-settings-daemon-schemas xclip xml-core xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-libinput
  xserver-xorg-legacy
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  apparmor* apport* apport-gtk* aptdaemon* apturl* apturl-common* blueman* command-not-found* deja-dup* dkms*
  docker-compose* duplicity* firefox* foomatic-db-compressed-ppds* gdm3* gedit* gedit-common* gnome-control-center*
  gnome-getting-started-docs* gnome-getting-started-docs-fr* gnome-menus* gnome-online-accounts* gnome-panel* gnome-shell*
  gnome-shell-extension-appindicator* gnome-shell-extension-desktop-icons* gnome-shell-extension-ubuntu-dock*
  gnome-software* gnome-software-plugin-snap* gnome-terminal* gnome-user-docs* gnome-user-docs-fr* gnome-user-guide* ibus*
  ibus-table* indicator-applet* indicator-bluetooth* language-selector-common* language-selector-gnome* lsb-release*
  nautilus-extension-gnome-terminal* nautilus-share* netplan.io* openprinting-ppds* orca* plymouth-theme-spinner*
  plymouth-theme-ubuntu-text* printer-driver-foo2zjs* printer-driver-foo2zjs-common* printer-driver-m2300w*
  printer-driver-ptouch* printer-driver-pxljr* printer-driver-sag-gdi* python3* python3-apport* python3-apt*
  python3-aptdaemon* python3-aptdaemon.gtk3widgets* python3-atomicwrites* python3-attr* python3-bcrypt* python3-blinker*
  python3-brlapi* python3-cached-property* python3-cairo* python3-certifi* python3-cffi-backend* python3-chardet*
  python3-click* python3-colorama* python3-commandnotfound* python3-crypto* python3-cryptography* python3-cups*
  python3-cupshelpers* python3-dateutil* python3-dbus* python3-debconf* python3-debian* python3-defer* python3-distro*
  python3-distro-info* python3-distupgrade* python3-distutils* python3-docker* python3-dockerpty* python3-docopt*
  python3-docutils* python3-entrypoints* python3-fasteners* python3-future* python3-gdbm* python3-gi* python3-gi-cairo*
  python3-httplib2* python3-ibus-1.0* python3-idna* python3-importlib-metadata* python3-jsonschema* python3-jwt*
  python3-keyring* python3-keyrings.alt* python3-kivy* python3-launchpadlib* python3-lazr.restfulclient* python3-lazr.uri*
  python3-lib2to3* python3-lockfile* python3-louis* python3-macaroonbakery* python3-monotonic* python3-more-itertools*
  python3-nacl* python3-netifaces* python3-oauthlib* python3-olefile* python3-packaging* python3-paramiko* python3-pexpect*
  python3-pil* python3-pip* python3-pkg-resources* python3-pluggy* python3-problem-report* python3-protobuf*
  python3-ptyprocess* python3-py* python3-pyatspi* python3-pygments* python3-pymacaroons* python3-pyparsing*
  python3-pyrsistent* python3-pytest* python3-requests* python3-requests-unixsocket* python3-rfc3339* python3-roman*
  python3-secretstorage* python3-setuptools* python3-simplejson* python3-six* python3-software-properties* python3-speechd*
  python3-systemd* python3-texttable* python3-tz* python3-update-manager* python3-urllib3* python3-wadllib* python3-wcwidth*
  python3-websocket* python3-wheel* python3-xdg* python3-xkit* python3-yaml* python3-zipp* python3.8* snapd*
  software-properties-common* software-properties-gtk* ssh-import-id* system-config-printer* system-config-printer-common*
  system-config-printer-udev* ubuntu-advantage-tools* ubuntu-desktop* ubuntu-desktop-minimal* ubuntu-docs*
  ubuntu-drivers-common* ubuntu-minimal* ubuntu-release-upgrader-core* ubuntu-release-upgrader-gtk* ubuntu-session*
  ubuntu-software* ubuntu-standard* ufw* unattended-upgrades* update-manager* update-manager-core* update-notifier*
  update-notifier-common* usb-creator-common* usb-creator-gtk* virtualbox-dkms* xorg* xserver-xorg* yelp* zoom*
0 upgraded, 0 newly installed, 188 to remove and 6 not upgraded.

What I tried

Removed Python 3 and now Ubuntu Software Center, terminal and other applications don't work

Command $ sudo apt-get install python3-all

Output

Les paquets suivants contiennent des dépendances non satisfaites :
 python3-all : Dépend: python3 (= 3.8.2-0ubuntu2) mais ne sera pas installé
               Dépend: python3-distutils (>= 3.8.2-1~) mais ne sera pas installé
               Dépend: python3.8 mais ne sera pas installé
E: Impossible de corriger les problèmes, des paquets défectueux sont en mode "garder en l'état"

Removed python3 hoping to reinstall it, but cannot do it

Command
I first installed aptitude $ sudo apt install aptitude and then ran $ sudo aptitude install python3

Output

Les paquets suivants ont des dépendances non satisfaites :
 python3.8 : Dépend: python3.8-minimal (= 3.8.5-1~20.04.2) but 3.8.8-1+bionic2 is installed
             Dépend: libpython3.8-stdlib (= 3.8.5-1~20.04.2) but 3.8.8-1+bionic2 is installed

Why did removing 'python3' remove many other important packages?

Command sudo apt-get install -f ubuntu-minimal ubuntu-desktop

Output

Les paquets suivants contiennent des dépendances non satisfaites :
 ubuntu-desktop : Dépend: foomatic-db-compressed-ppds mais ne sera pas installé
                  Dépend: gdm3 mais ne sera pas installé
                  Dépend: gnome-control-center mais ne sera pas installé
                  Dépend: gnome-menus mais ne sera pas installé
                  Dépend: gnome-shell mais ne sera pas installé
                  Dépend: gnome-shell-extension-appindicator mais ne sera pas installé
                  Dépend: gnome-shell-extension-desktop-icons mais ne sera pas installé
                  Dépend: gnome-shell-extension-ubuntu-dock mais ne sera pas installé
                  Dépend: language-selector-gnome mais ne sera pas installé
                  Dépend: openprinting-ppds mais ne sera pas installé
                  Dépend: software-properties-gtk mais ne sera pas installé
                  Dépend: ubuntu-desktop-minimal mais ne sera pas installé
                  Dépend: ubuntu-drivers-common mais ne sera pas installé
                  Dépend: ubuntu-release-upgrader-gtk mais ne sera pas installé
                  Dépend: ubuntu-session mais ne sera pas installé
                  Dépend: update-manager mais ne sera pas installé
                  Dépend: xorg mais ne sera pas installé
                  Dépend: yelp mais ne sera pas installé
                  Recommande: apport-gtk mais ne sera pas installé
                  Recommande: deja-dup mais ne sera pas installé
                  Recommande: eog mais ne sera pas installé
                  Recommande: firefox mais ne sera pas installé
                  Recommande: gedit mais ne sera pas installé
                  Recommande: gnome-getting-started-docs mais ne sera pas installé
                  Recommande: gnome-terminal mais ne sera pas installé
                  Recommande: gnome-todo mais ne sera pas installé
                  Recommande: hplip mais ne sera pas installé
                  Recommande: ibus
                  Recommande: ibus-table mais ne sera pas installé
                  Recommande: nautilus-share mais ne sera pas installé
                  Recommande: orca mais ne sera pas installé
                  Recommande: plymouth-theme-spinner mais ne sera pas installé
                  Recommande: printer-driver-foo2zjs mais ne sera pas installé
                  Recommande: printer-driver-m2300w mais ne sera pas installé
                  Recommande: printer-driver-ptouch mais ne sera pas installé
                  Recommande: printer-driver-pxljr mais ne sera pas installé
                  Recommande: printer-driver-sag-gdi mais ne sera pas installé
                  Recommande: rhythmbox mais ne sera pas installé
                  Recommande: snapd mais ne sera pas installé
                  Recommande: system-config-printer mais ne sera pas installé
                  Recommande: totem mais ne sera pas installé
                  Recommande: ubuntu-docs mais ne sera pas installé
                  Recommande: usb-creator-gtk mais ne sera pas installé
 ubuntu-minimal : Dépend: lsb-release mais ne sera pas installé
                  Dépend: netplan.io mais ne sera pas installé
                  Dépend: python3 mais ne sera pas installé
                  Dépend: ubuntu-advantage-tools mais ne sera pas installé
E: Impossible de corriger les problèmes, des paquets défectueux sont en mode "garder en l'état"

Command $ sudo apt -f install --reinstall libpython3.8-stdlib=3.8.5-1~20.04.2

Output

Lecture des listes de paquets…
Construction de l'arbre des dépendances…
Lecture des informations d'état…
Vous pouvez lancer « apt --fix-broken install » pour corriger ces problèmes.
Les paquets suivants contiennent des dépendances non satisfaites :
 libpython3.8-stdlib : Dépend: libpython3.8-minimal (= 3.8.5-1~20.04.2) mais 3.8.8-1+bionic2 devra être installé
 python3 : Dépend: python3.8 (>= 3.8.2-1~) mais ne sera pas installé
E: Dépendances non satisfaites. Essayer "apt --fix-broken install" sans paquet

Command $ apt-cache policy

Output

Fichiers du paquet :
 100 /var/lib/dpkg/status
     release a=now
 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
     release o=Docker,a=focal,l=Docker CE,c=stable,b=amd64
     origin download.docker.com
 500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main i386 Packages
     release v=20.04,o=LP-PPA-deadsnakes,a=focal,n=focal,l=New Python Versions,c=main,b=i386
     origin ppa.launchpad.net
 500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages
     release v=20.04,o=LP-PPA-deadsnakes,a=focal,n=focal,l=New Python Versions,c=main,b=amd64
     origin ppa.launchpad.net
 500 http://security.ubuntu.com/ubuntu focal-security/multiverse i386 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=multiverse,b=i386
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=multiverse,b=amd64
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=universe,b=i386
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=universe,b=amd64
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/restricted i386 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=restricted,b=i386
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=restricted,b=amd64
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=main,b=i386
     origin security.ubuntu.com
 500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=main,b=amd64
     origin security.ubuntu.com
 500 http://archive.canonical.com/ubuntu focal/partner amd64 Packages
     release v=20.04,o=Canonical,a=focal,n=focal,l=Partner archive,c=partner,b=amd64
     origin archive.canonical.com
 100 http://ch.archive.ubuntu.com/ubuntu focal-backports/universe i386 Packages
     release v=20.04,o=Ubuntu,a=focal-backports,n=focal,l=Ubuntu,c=universe,b=i386
     origin ch.archive.ubuntu.com
 100 http://ch.archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-backports,n=focal,l=Ubuntu,c=universe,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/multiverse i386 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=multiverse,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=multiverse,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=universe,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=universe,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/restricted i386 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=restricted,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=restricted,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=main,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
     release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=main,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/multiverse i386 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=multiverse,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=multiverse,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/universe i386 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/restricted i386 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=restricted,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/restricted amd64 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=restricted,b=amd64
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/main i386 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=main,b=i386
     origin ch.archive.ubuntu.com
 500 http://ch.archive.ubuntu.com/ubuntu focal/main amd64 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=main,b=amd64
     origin ch.archive.ubuntu.com
Paquets épinglés :
Plouc314
  • 1
  • 3
  • 1
    You removed the version of python that Ubuntu 20.04 can not work without. Each version of Ubuntu has a version of python it needs. – David Apr 05 '21 at 11:07
  • You'll need at a minimum python3-minimal installed (which will install python 3.8) before a number of things work. Did your apt commands work, as they tend not to until that package is installed (ie. you mention many commands but don't mention if they worked or gave errors, nor if you fixed any errors...). Usually you have to use wget and dpkg to download & install given apt & apt-get tools require you to fix the python issue first before they'll work... – guiverc Apr 05 '21 at 11:31
  • @guiverc : I had the part of the outputs of the commands, none of them worked. I have python3-minimal installed (3.8.2-0ubuntu2) and apt seems to work as I was able to install aptitude with it. You can see complete outputs of all commands going here – Plouc314 Apr 05 '21 at 14:58
  • @Plouc314 you might be able to download the deb-file for python3 from https://packages.ubuntu.com/focal/python3 then do a sudo dpkg -i python3.deb (replace the file name with the downloaded) to "jump start" the rest of the installation. You will still need to fix dependencies through aptitude and similar – Rohde Fischer Apr 05 '21 at 16:27
  • 1
    @RohdeFischer I downloaded python3_3.8.2-0ubuntu2_amd64.deb and tried $ sudo dpkg -i python3_3.8.2-0ubuntu2_amd64.deb but got dependencies errors : python3 dépend de python3.8 (>= 3.8.2-1~) ; cependant : Le paquet python3.8 n'est pas installé. So it seems like it didn't help – Plouc314 Apr 05 '21 at 16:44
  • Oh you might be right, not sure why that usually worked for me. I think you can overrule that by doing: sudo dpkg --force-depends -i python3_3.8.2-0ubuntu2_amd64.deb – Rohde Fischer Apr 05 '21 at 17:30
  • @RohdeFischer It looks like I'm able to install with --force-depends but I still got python3 dépend de python3.8 (>= 3.8.2-1~) mais ne sera pas installé when I try $ sudo apt install python3 for example – Plouc314 Apr 05 '21 at 17:46
  • Digged a bit around, my best suggestion right now is to try and use apt-cache show python3 combined with sudo apt-get download and sudo dpkg -i to resolve the dependencies manually. But it might be quite a bit of work. Sorry, mate :/ I wish I had better – Rohde Fischer Apr 05 '21 at 18:40
  • sudo apt -f install --reinstall libpython3.8-stdlib=3.8.5-1~20.04.2 show us please and apt-cache policy please not as comment; edit your question instead. – nobody Apr 05 '21 at 19:00
  • Let me guess it was an upgrade from bionic? – nobody Apr 05 '21 at 20:52
  • @nobody I upgraded from ubuntu 18 to 20 quite recently but part of that I have no idea of what is bionic – Plouc314 Apr 06 '21 at 06:48
  • bionic = ubuntu 18.04 – nobody Apr 06 '21 at 07:51

0 Answers0