Ubuntu 20.04 LTS: no se pueden instalar más paquetes ni actualizaciones debido a problemas con la versión de Python: cómo limpiar

Ubuntu 20.04 LTS: no se pueden instalar más paquetes ni actualizaciones debido a problemas con la versión de Python: cómo limpiar

---Se proporciona una actualización (más detalles) en la parte inferior.---

Realicé con éxito una actualización en la distribución de Ubuntu 19.04 a 20.04 LTS. Esto ya fue hace un tiempo y la máquina es mi cliente de trabajo diario. En este momento pude aplicar las actualizaciones de Ubuntu. Tengo muchos paquetes instalados. La mayoría fueron instalados mediante el clásico sistema de gestión de paquetes apt-get.

Mientras tanto, he instalado algunos paquetes que requieren diferentes versiones de Python. Ahora tengo problemas graves porque desde entonces no puedo instalar nada en mi sistema.

He leído muchas publicaciones que abordan este caos de Python sin una solución final. Y soy consciente de que para el futuro tendré que usar pip o docker. Entonces haré esto.

Pero en este momento dependo de mi cliente de trabajo diario y no hay posibilidad de hacerlo nuevo.

¿Hay alguna manera de configurar un estado nativo estable para Python como si hiciera una nueva instalación (una especie de estado de reinicio)? Además, si después de eso, algunos programas de usuario basados ​​en Python no se ejecutan.

No puedo localizar cuándo surgieron estos problemas. A continuación presento algunos análisis de mi sistema.

He visto que algunas instalaciones de programas detenidas con la administración de paquetes (apt-get install) sobrescribirán todo el sistema /usr/bin/python2 -> python2.7, pero esto se niega. Sospecho firmemente que esto se debe a la dependencia de python-gtk2, porque este error/mensaje de hace unas semanas estaba solo. Al intentar resolver el problema, aparece este nuevo mensaje para python-enchant.

Muchas gracias de antemano por las ideas útiles.

------Mi sistema (lo siento, esta es una localización alemana)

user@mymachine:~$ **lsb_release -a**
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

usuario@mimáquina:~$lista de sudo snap

Name                Version          Revision  Tracking       Herausgeber  Hinweise
core                16-2.49.2        10958     latest/stable  canonical?   core
core18              20210309         1997      latest/stable  canonical?   base
go                  1.16.3           7360      latest/stable  mwhudson     classic
gtk-common-themes   0.1-52-gb92ac40  1515      latest/stable  canonical?   -
gtk2-common-themes  0.1              13        latest/stable  canonical?   -

------Uso de Python dentro de la sesión real

usuario@mimáquina: ~$ps auxiliar | pitón grep

root        1213  0.0  0.0  39732 14776 ?        Ss   Mai02   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root        1601  0.0  0.1 118480 16892 ?        Ssl  Mai02   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user          3120  0.0  0.1 435708 27452 ?        Sl   Mai02   0:00 /usr/bin/python3 /usr/bin/blueman-applet
user          3125  0.0  0.1  65492 32024 ?        S    Mai02   0:00 /usr/bin/python3 /usr/share/system-config-printer/applet.py
user          3245  0.0  0.1 360956 28980 ?        Sl   Mai02   0:00 /usr/bin/python3 /usr/bin/blueman-tray
user         22367  0.0  0.0   9412   672 pts/4    S+   10:39   0:00 grep --color=auto python

*------Después de una instalación de paquete o sudo apt-upgrade a través de.deb o sudo apt-get install Recibo un mensaje de problema de dependencia:

Die folgenden Pakete haben unerfüllte Abhängigkeiten:

 python-enchant : Hängt ab von: python:any (>= 2.7.5-5~)
                  Hängt ab von: python:any (< 2.8)
 python-gtk2 : Hängt ab von: python (>= 2.7)
               Hängt ab von: python (< 2.8)
 python-gtksourceview2 : Hängt ab von: python (>= 2.7)
                         Hängt ab von: python (< 2.8)
E: Unerfüllte Abhängigkeiten. Versuchen Sie »apt --fix-broken install« ohne Angabe eines Pakets (oder geben Sie eine Lösung an).

------Análisis de Python usuario@mimáquina:~$*dpkg-l | grep libpython.mínimo

ii  libpython2.7-minimal:amd64                    2.7.18-1~20.04                        amd64        Minimal subset of the Python language (version 2.7)
ii  libpython3.7-minimal:amd64                    3.7.5-2~19.10ubuntu1                  amd64        Minimal subset of the Python language (version 3.7)
ii  libpython3.8-minimal:amd64                    3.8.5-1~20.04                         amd64        Minimal subset of the Python language (version 3.8)

usuario@mimáquina:~$sudo apt-cache --installed -i --recurse rdepends libpython3.8-minimal | grep "^" | ordenar -u |xargs apt-mark auto

apport wurde bereits auf automatisch installiert gesetzt.
aptdaemon wurde bereits auf automatisch installiert gesetzt.
apturl-common wurde bereits auf automatisch installiert gesetzt.
command-not-found wurde bereits auf automatisch installiert gesetzt.
gdb wurde bereits auf automatisch installiert gesetzt.
gir1.2-peas-1.0 wurde bereits auf automatisch installiert gesetzt.
gnome-software-plugin-snap wurde bereits auf automatisch installiert gesetzt.
ibus wurde bereits auf automatisch installiert gesetzt.
Markierung für ibus:i386 kann nicht gesetzt werden, da es nicht installiert ist.
language-selector-common wurde bereits auf automatisch installiert gesetzt.
Markierung für libglib2.0-dev-bin:i386 kann nicht gesetzt werden, da es nicht installiert ist.
libpeas-1.0-0 wurde bereits auf automatisch installiert gesetzt.
libpurple-bin wurde bereits auf automatisch installiert gesetzt.
libpython3.8 wurde bereits auf automatisch installiert gesetzt.
libpython3.8-stdlib wurde bereits auf automatisch installiert gesetzt.
libpython3-stdlib wurde bereits auf automatisch installiert gesetzt.
libsmbclient wurde bereits auf automatisch installiert gesetzt.
netplan.io wurde bereits auf automatisch installiert gesetzt.
networkd-dispatcher wurde bereits auf automatisch installiert gesetzt.
onboard-common wurde bereits auf automatisch installiert gesetzt.
onboard-data wurde bereits auf automatisch installiert gesetzt.
printer-driver-foo2zjs-common wurde bereits auf automatisch installiert gesetzt.
printer-driver-postscript-hp wurde bereits auf automatisch installiert gesetzt.
python3.8 wurde bereits auf automatisch installiert gesetzt.
python3.8-minimal wurde bereits auf automatisch installiert gesetzt.
python3-apport wurde bereits auf automatisch installiert gesetzt.
python3-apsw wurde bereits auf automatisch installiert gesetzt.
python3-apt wurde bereits auf automatisch installiert gesetzt.
python3-aptdaemon wurde bereits auf automatisch installiert gesetzt.
python3-aptdaemon.gtk3widgets wurde bereits auf automatisch installiert gesetzt.
python3-cairo wurde bereits auf automatisch installiert gesetzt.
python3-cffi-backend wurde bereits auf automatisch installiert gesetzt.
python3-chm wurde bereits auf automatisch installiert gesetzt.
python3-commandnotfound wurde bereits auf automatisch installiert gesetzt.
python3-crypto wurde bereits auf automatisch installiert gesetzt.
python3-cryptography wurde bereits auf automatisch installiert gesetzt.
python3-cssselect wurde bereits auf automatisch installiert gesetzt.
python3-cups wurde bereits auf automatisch installiert gesetzt.
python3-cupshelpers wurde bereits auf automatisch installiert gesetzt.
python3-dbus wurde bereits auf automatisch installiert gesetzt.
python3-debianbts wurde bereits auf automatisch installiert gesetzt.
python3-distupgrade wurde bereits auf automatisch installiert gesetzt.
python3-gdbm wurde bereits auf automatisch installiert gesetzt.
python3-gi wurde bereits auf automatisch installiert gesetzt.
python3-gi-cairo wurde bereits auf automatisch installiert gesetzt.
python3-gpg wurde bereits auf automatisch installiert gesetzt.
python3-html5-parser wurde bereits auf automatisch installiert gesetzt.
python3-ibus-1.0 wurde bereits auf automatisch installiert gesetzt.
python3-keyring wurde bereits auf automatisch installiert gesetzt.
python3-launchpadlib wurde bereits auf automatisch installiert gesetzt.
python3-lazr.restfulclient wurde bereits auf automatisch installiert gesetzt.
python3-ldb wurde bereits auf automatisch installiert gesetzt.
python3-lxml wurde bereits auf automatisch installiert gesetzt.
python3-minimal wurde bereits auf automatisch installiert gesetzt.
python3-msgpack wurde bereits auf automatisch installiert gesetzt.
python3-nacl wurde bereits auf automatisch installiert gesetzt.
python3-netifaces wurde bereits auf automatisch installiert gesetzt.
python3-numpy wurde bereits auf automatisch installiert gesetzt.
python3-oauthlib wurde bereits auf automatisch installiert gesetzt.
python3-odf wurde bereits auf automatisch installiert gesetzt.
python3-pil wurde bereits auf automatisch installiert gesetzt.
python3-psutil wurde bereits auf automatisch installiert gesetzt.
python3-pycurl wurde bereits auf automatisch installiert gesetzt.
python3-pymacaroons wurde bereits auf automatisch installiert gesetzt.
python3-pyqt5.qtsvg wurde bereits auf automatisch installiert gesetzt.
python3-pyqt5.qtwebchannel wurde bereits auf automatisch installiert gesetzt.
python3-pyqt5.qtwebengine wurde bereits auf automatisch installiert gesetzt.
python3-pysimplesoap wurde bereits auf automatisch installiert gesetzt.
python3-regex wurde bereits auf automatisch installiert gesetzt.
python3-renderpm wurde bereits auf automatisch installiert gesetzt.
python3-reportlab wurde bereits auf automatisch installiert gesetzt.
python3-reportlab-accel wurde bereits auf automatisch installiert gesetzt.
python3-samba wurde bereits auf automatisch installiert gesetzt.
python3-sane wurde bereits auf automatisch installiert gesetzt.
python3-secretstorage wurde bereits auf automatisch installiert gesetzt.
python3-setuptools wurde bereits auf automatisch installiert gesetzt.
python3-simplejson wurde bereits auf automatisch installiert gesetzt.
python3-software-properties wurde bereits auf automatisch installiert gesetzt.
python3-systemd wurde bereits auf automatisch installiert gesetzt.
python3-talloc wurde bereits auf automatisch installiert gesetzt.
python3-tdb wurde bereits auf automatisch installiert gesetzt.
python3-tk wurde bereits auf automatisch installiert gesetzt.
python3-uno wurde bereits auf automatisch installiert gesetzt.
python3-update-manager wurde bereits auf automatisch installiert gesetzt.
python3-urwid wurde bereits auf automatisch installiert gesetzt.
python3-webob wurde bereits auf automatisch installiert gesetzt.
python3-yaml wurde bereits auf automatisch installiert gesetzt.
python-apt-common wurde bereits auf automatisch installiert gesetzt.
python-odf-tools wurde bereits auf automatisch installiert gesetzt.
samba-common-bin wurde bereits auf automatisch installiert gesetzt.
samba-dsdb-modules wurde bereits auf automatisch installiert gesetzt.
samba-libs wurde bereits auf automatisch installiert gesetzt.
system-config-printer-common wurde bereits auf automatisch installiert gesetzt.
system-config-printer-udev wurde bereits auf automatisch installiert gesetzt.
ubuntu-advantage-tools wurde bereits auf automatisch installiert gesetzt.
ubuntu-release-upgrader-core wurde bereits auf automatisch installiert gesetzt.
unattended-upgrades wurde bereits auf automatisch installiert gesetzt.
virtualbox-qt wurde bereits auf automatisch installiert gesetzt.
xserver-xorg wurde bereits auf automatisch installiert gesetzt.
Markierung für xserver-xorg-hwe-16.04 kann nicht gesetzt werden, da es nicht installiert ist.
E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Keine Berechtigung)
E: Temporäres StateFile /var/lib/apt/extended_states konnte nicht geschrieben werden.

usuario@mimáquina: ~$apt-cache rdepends -i --installed --recurse python2 | grep -v " " | ordenar -u

calibre
font-manager
gimp
meld
nautilus-dropbox
ocrfeeder
python2
python-apsw
python-cairo
python-cffi-backend
python-crypto
python-cryptography
python-dbus
python-gi
python-gobject
python-gobject-2
python-gtk2
python-gtksourceview2
python-libxml2
python-lxml
python-netifaces
python-numpy
python-openssl
python-pil
python-simplejson
python-sip
python-tk
python-yaml
scribus
scribus-data

usuario@mimáquina: ~$ls -al /usr/bin/python*

lrwxrwxrwx 1 root root      24 Feb 24 14:48 /usr/bin/python -> /etc/alternatives/python
lrwxrwxrwx 1 root root       9 Feb 24  2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3629032 Aug  4  2020 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Aug  4  2020 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root       9 Mär 13  2020 /usr/bin/python3 -> python3.8
-rwxr-xr-x 2 root root 5102632 Apr 19  2020 /usr/bin/python3.7
-rwxr-xr-x 2 root root 5102632 Apr 19  2020 /usr/bin/python3.7m
-rwxr-xr-x 1 root root 5486352 Jul 28  2020 /usr/bin/python3.8

--- Actualización 01 ---

Hola, aquí te doy el resultado completo de sudo apt -f install:

Si puede ver, hay un bloqueo de la versión de Python para todo el sistema (2.7.17-1), que debe actualizarse con este paquete: python-is-python2_2.7.17-4_all.deb

user@mymachine: ~$ sudo apt -f install
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.       
Statusinformationen werden eingelesen.... Fertig
Abhängigkeiten werden korrigiert ... Fertig
Die folgenden Pakete wurden automatisch installiert und werden nicht mehr benötigt:
  gcc-9-base:i386 geoip-database libapt-pkg5.90 libart-2.0-2 libbind9-161
  libbonobo2-0 libbonobo2-common libbonoboui2-0 libbonoboui2-common
  libboost-date-time1.67.0 libboost-iostreams1.67.0 libboost-locale1.67.0
  libboost-thread1.67.0 libbrlapi0.6 libcodec2-0.8.1 libdns-export1104
  libdns1104 libdns1109 libdvdread4 libevent-2.1-6 libevent-core-2.1-6
  libevent-pthreads-2.1-6 libexiv2-14 libffi6 libffi6:i386 libfluidsynth1
  libgeoip1 libgnome-2-0 libgnome-desktop-3-18 libgnome2-0 libgnome2-bin
  libgnome2-common libgnomecanvas2-0 libgnomecanvas2-common libgnomeui-0
  libgnomeui-common libgnomevfs2-0 libgnomevfs2-common libgsoap-2.8.75
  libgspell-1-1 libgutenprint-common libgutenprint9 libhogweed4
  libhogweed4:i386 libicu63 libicu63:i386 libidl-2-0 libilmbase23 libiptc0
  libirs161 libisc-export1100 libisc1100 libisc1105 libisccc161 libisccfg163
  libisl21 libjte1 libllvm9 liblouis17 liblwres161 libmypaint-1.3-0 libmysofa0
  libnettle6 libnettle6:i386 libnfs12 liboauth0 libopenexr23 liborbit-2-0
  liborbit2 liborcus-0.14-0 libpangox-1.0-0 libplymouth4 libpoppler90
  libpython-stdlib libpython3.7 libpython3.7-minimal libpython3.7-stdlib
  libqpdf21 libusbmuxd4 libwnck-common libwnck22 libx265-176
  linux-headers-5.3.0-62 linux-headers-5.3.0-62-generic
  linux-image-5.3.0-62-generic linux-modules-5.3.0-62-generic
  linux-modules-extra-5.3.0-62-generic node-is-builtin-module node-node-uuid
  printer-driver-gutenprint python-blinker python-certifi python-crypto
  python-httplib2 python-idna python-minimal python-pyasn1
  python-pyasn1-modules python-tz python-xdg python3-asn1crypto python3-nacl
  python3-pymacaroons python3.7 python3.7-minimal
Verwenden Sie »sudo apt autoremove«, um sie zu entfernen.
Die folgenden zusätzlichen Pakete werden installiert:
  python-is-python2
Die folgenden NEUEN Pakete werden installiert:
  python-is-python2
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 220 nicht aktualisiert.
5 nicht vollständig installiert oder entfernt.
Es müssen noch 0 B von 2.496 B an Archiven heruntergeladen werden.
Nach dieser Operation werden 10,2 kB Plattenplatz zusätzlich benutzt.
Möchten Sie fortfahren? [J/n] j
(Lese Datenbank ... 376668 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von .../python-is-python2_2.7.17-4_all.deb ...
Entpacken von python-is-python2 (2.7.17-4) ...
dpkg: Fehler beim Bearbeiten des Archivs /var/cache/apt/archives/python-is-pytho
n2_2.7.17-4_all.deb (--unpack):
 Versuch, »/usr/bin/python« zu überschreiben, welches auch in Paket python-minim
al 2.7.17-1 ist
Fehler traten auf beim Bearbeiten von:
 /var/cache/apt/archives/python-is-python2_2.7.17-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

--- Actualización 02 ---

¿Cómo puedo cambiar el candidato de instalación (2.7.12-1~16.04)? ¿Este podría ser el problema porque es una fuente no válida?

sudo apt-cache policy python
python:
  Installiert:           (keine)
  Installationskandidat: 2.7.12-1~16.04
  Versionstabelle:
     2.7.17-1 -1
        100 /var/lib/dpkg/status
     2.7.12-1~16.04 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages

información relacionada