在 Ubuntu 18.04 中意外删除 python3 后软件包管理不善

在 Ubuntu 18.04 中意外删除 python3 后软件包管理不善

升级到 Ubuntu 18.04 LTS 后,我收到以下错误

bash: /usr/bin/python3: No such file or directory
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is set properly.

因此,在网上搜索了这个问题之后,我运行了命令sudo apt remove python3,从我的操作系统中删除了大部分东西,比如 Chrome、GUI 等。我能够恢复我的 GUI,但是当我运行命令时,sudo apt upgrade我收到以下错误

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
106 not fully installed or removed.
Need to get 0 B/47.2 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
dpkg: error processing package python3 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
No apport report written because the error message indicates it's a follow-up error from a previous failure.
dpkg: dependency problems prevent configuration of update-notifier-common:
 update-notifier-common depends on python3:any; however:
  Package python3 is not configured yet.

dpkg: error processing package update-notifier-common (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-lxml:amd64:
 python3-lxml:amd64 depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 python3-lxml:amd64 depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.
 python3-lxml:amd64 depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-lxml:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of printer-driver-m2300w:
 printer-driver-m2300w depends on python3; however:
  Package python3 is not configured yet.

dpkg: error pNo apport report written because the error message indicates it's a follow-up error from a previous failure.
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached

No apport report written because MaxReports has already been reached
Processing package printer-driver-m2300w (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of usb-creator-gtk:
 usb-creator-gtk depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package usb-creator-gtk (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-olefile:
 python3-olefile depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-olefile (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ubuntu-web-launchers:
 ubuntu-web-launchers depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package ubuntu-web-launchers (--configure):
 dependency problems - leaving unconfigured
dpkg: dependNo apport report written because MaxReports has already been reached

No apport report written because MaxReports has already been reached
dpkg: dependency problems prevent configuration of libglib2.0-dev-bin:
 libglib2.0-dev-bin depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package libglib2.0-dev-bin (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of rhythmbox-plugin-zeitgeist:
 rhythmbox-plugin-zeitgeist depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package rhythmbox-plugin-zeitgeist (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-brlapi:
 python3-brlapi depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 python3-brlapi depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.
 python3-brlapi depends on python3:any (>= 3.2~); however:
  Package python3 is not configured yet.

dpkg: error proNo apport report written because MaxReports has already been reached
 Processing package python3-brlapi (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-commandnotfound:
 python3-commandnotfound depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-commandnotfound (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of printer-driver-postscript-hp:
 printer-driver-postscript-hp depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package printer-driver-postscript-hp (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-numpy:
 python3-numpy depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 python3-numpy depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.
 python3-numpy depends on python3:any (>= 3.4~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-numpy (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of system-config-printer-common:
 system-config-printer-common depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package system-config-printer-common (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of language-selector-common:
 language-selector-common depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
dpkg: error processing package language-selector-common (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of printer-driver-foo2zjs-common:
 printer-driver-foo2zjs-common depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package printer-driver-foo2zjs-common (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-keyrings.alt:
 python3-keyrings.alt depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
dpkg: error processing package python3-keyrings.alt (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of apt-xapian-index:
 apt-xapian-index depends on python3:any (>= 3.4~); however:
  Package python3 is not configured yet.

dpkg: error processing package apt-xapian-index (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
dpkg: dependency problems prevent configuration of openprinting-ppds:
 openprinting-ppds depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package openprinting-ppds (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of apparmor:
 apparmor depends on python3:any; however:
  Package python3 is not configured yet.

dpkg: error processing package apparmor (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of gnome-shell:
 gnome-shell depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package gnome-shell (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of apport-gtk:
 apport-gtk depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package apport-gtk (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-aptdaemon.gtk3widgets:
 python3-aptdaemon.gtk3widgets depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-aptdaemon.gtk3widgets (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of apturl:
 apturl depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
 apturl depends on python3-aptdaemon.gtk3widgets; however:
  Package python3-aptdaemon.gtk3widgets is not configured yet.

dpkg: error processing package apturl (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-wheel:
 python3-wheel depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-wheel (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-gi-cairo:
 python3-gi-cairo depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 python3-gi-cairo depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.
 python3-gi-cairo depends on python3:any (>= 3.3~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-gi-cairo (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of hplip-data:
 hplip-data depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package hplip-data (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-bs4:
 python3-bs4 depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-bs4 (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of lsb-release:
 lsb-release depends on python3:any (>= 3.4~); however:
  Package python3 is not configured yet.

dpkg: error processing package lsb-release (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of gnome-control-center:
 gnome-control-center depends on system-config-printer-common (>= 1.4); however:
  Package system-config-printer-common is not configured yet.

dpkg: error processing package gnome-control-center (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of orca:
 orca depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
 orca depends on python3-brlapi (>= 0.5.1); however:
  Package python3-brlapi is not configured yet.

dpkg: error processing package orca (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of gnome-terminal:
 gnome-terminal depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package gnome-terminal (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of ubuntu-session:
 ubuntu-session depends on gnome-shell (>= 3.24.3-0ubuntu2); however:
  Package gnome-shell is not configured yet.

dpkg: error processing package ubuntu-session (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-asn1crypto:
 python3-asn1crypto depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
dpkg: error processing package python3-asn1crypto (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-blinker:
 python3-blinker depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-blinker (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-reportlab:
 python3-reportlab depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-reportlab (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of gnome-tweaks:
 gnome-tweaks depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package gnome-tweaks (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-feedparser:
 python3-feedparser depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-feedparser (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-macaroonbakery:
 python3-macaroonbakery depends on python3:any (>= 3.5~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-macaroonbakery (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of snapd:
 snapd depends on apparmor (>= 2.10.95-0ubuntu2.2); however:
  Package apparmor is not configured yet.

dpkg: error processing package snapd (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of printer-driver-pxljr:
 printer-driver-pxljr depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package printer-driver-pxljr (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-debconf:
 python3-debconf depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-debconf (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-uno:
 python3-uno depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
 python3-uno depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 python3-uno depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-uno (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of software-properties-gtk:
 software-properties-gtk depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.
 software-properties-gtk depends on python3; however:
  Package python3 is not configured yet.
 software-properties-gtk depends on python3-aptdaemon.gtk3widgets; however:
  Package python3-aptdaemon.gtk3widgets is not configured yet.

dpkg: error processing package software-properties-gtk (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-oauthlib:
 python3-oauthlib depends on python3:any (>= 3.4~); however:
  Package python3 is not configured yet.
 python3-oauthlib depends on python3-blinker; however:
  Package python3-blinker is not configured yet.

dpkg: error processing package python3-oauthlib (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of ubuntu-system-service:
 ubuntu-system-service depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package ubuntu-system-service (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-pexpect:
 python3-pexpect depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-pexpect (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-systemd:
 python3-systemd depends on python3 (<< 3.7); however:
  Package python3 is not configured yet.
 python3-systemd depends on python3 (>= 3.6~); however:
  Package python3 is not configured yet.
 python3-systemd depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-systemd (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of xdiagnose:
 xdiagnose depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package xdiagnose (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of update-notifier:
 update-notifier depends on update-notifier-common (= 3.192.1.7); however:
  Package update-notifier-common is not configured yet.

dpkg: error processing package update-notifier (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: dependency problems prevent configuration of python3-all:
 python3-all depends on python3 (= 3.6.7-1~18.04); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-all (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached

dpkg: too many errors, stopping
Errors were encountered while processing:
 python3
 update-notifier-common
 python3-lxml:amd64
 printer-driver-m2300w
 usb-creator-gtk
 python3-olefile
 ubuntu-web-launchers
 libglib2.0-dev-bin
 rhythmbox-plugin-zeitgeist
 python3-brlapi
 python3-commandnotfound
 printer-driver-postscript-hp
 python3-numpy
 system-config-printer-common
 language-selector-common
 printer-driver-foo2zjs-common
 python3-keyrings.alt
 apt-xapian-index
 openprinting-ppds
 apparmor
 gnome-shell
 apport-gtk
 python3-aptdaemon.gtk3widgets
 apturl
 python3-wheel
 python3-gi-cairo
 hplip-data
 python3-bs4
 lsb-release
 gnome-control-center
 orca
 gnome-terminal
 ubuntu-session
 python3-asn1crypto
 python3-blinker
 python3-reportlab
 gnome-tweaks
 python3-feedparser
 python3-macaroonbakery
 snapd
 printer-driver-pxljr
 python3-debconf
 python3-uno
 software-properties-gtk
 python3-oauthlib
 ubuntu-system-service
 python3-pexpect
 python3-systemd
 xdiagnose
 update-notifier
 python3-all
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

有人能帮助我克服这种情况吗?

答案1

您的最后一个命令的输出清楚地表明了106 not fully installed or removed.这一点,应该通过在终端中发出以下命令来修复:

sudo apt-get install --fix-missing

如果此方法不能解决问题,请执行以下操作:

sudo dpkg --configure -a
sudo apt-get update
sudo apt-get dist-upgrade

相关内容