我将 Ubuntu 18.04 升级到了 20.04,现在一切都坏了。apt 不起作用。尝试使用它时不断出现 dpkg 错误。无法安装任何东西。nautilus 和终端不起作用。许多图标没有出现。损坏的图标 损坏的图标2 损坏的图标3
发生了一些 Python 错误等等。现在该怎么办?甚至备份程序都不起作用。如何让它再次工作?我不明白为什么 canonical 不能发送正确的升级
EDIT1:有什么方法可以删除并重新安装所有需要的软件包吗? apt 实际上可以工作,但会出现不同的错误。
EDIT2:举个例子,运行sudo apt install terminator
四分之一后的输出是:
.
.
.
dpkg: dependency problems prevent configuration of terminator:
terminator depends on python3-configobj; however:
Package python3-configobj is not configured yet.
terminator depends on python3-gi; however:
Package python3-gi is not configured yet.
terminator depends on python3-gi-cairo; however:
Package python3-gi-cairo is not configured yet.
terminator depends on python3-psutil; however:
Package python3-psutil is not configured yet.
terminator depends on python3:any; however:
Package python3 is not configured yet.
dpkg: error processing package terminator (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-nacl:
python3-nacl depends on python3 (>= 3~); however:
Package python3 is not configured yet.
python3-nacl depends on python3-six; however:
Package python3-six is not configured yet.
python3-nacl depends on python3:any; however:
Package python3 is not configured yet.
dpkg: error processing package python3-nacl (--configure):
dependency problems - leaving unconfigured
Setting up libgtk-3-common (3.24.20-0ubuntu1) ...
dpkg: dependency problems prevent configuration of python3-systemd:
python3-systemd depends on python3 (<< 3.9); however:
Package python3 is not configured yet.
python3-systemd depends on python3 (>= 3.8~); however:
Package python3 is not configured yet.
python3-systemd depends on python3:any; however:
Package python3 is not configured yet.
dpkg: error processing package python3-systemd (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-cffi-backend:
python3-cffi-backend depends on python3 (<< 3.9); however:
Package python3 is not configured yet.
python3-cffi-backend depends on python3 (>= 3.8~); however:
Package python3 is not configured yet.
dpkg: error processing package python3-cffi-backend (--configure):
dependency problems - leaving unconfigured
dpkg: too many errors, stopping
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for dictionaries-common (1.28.1) ...
Errors were encountered while processing:
python3
python3-psutil
apport
python3-tz
python3-apport
python3-cupshelpers
python3-monotonic
python3-requests-unixsocket
python3-six
python3-simplejson
python3-cups
python3-oauthlib
python3-chardet
python3-configobj
python3-secretstorage
system-config-printer
python3-certifi
python3-pexpect
python3-cryptography
python3-wadllib
python3-gi
python3-requests
python3-ldb
python3-idna
python3-fasteners
python3-urllib3
gnome-shell
ubuntu-session
ibus
gdm3
python3-defer
duplicity
python3-keyring
python3-httplib2
language-selector-common
python3-paramiko
lsb-release
python3-protobuf
python3-future
python3-rfc3339
python3-macaroonbakery
python3-aptdaemon.gtk3widgets
python3-ibus-1.0
python3-lazr.restfulclient
python3-gi-cairo
python3-lib2to3
terminator
python3-nacl
python3-systemd
python3-cffi-backend
Processing was halted because there were too many errors.
EDIT3:输出sudo apt-get install aptitude
:https://pastecode.io/s/9eo7pji8
输出sudo aptitude dist-upgrade
:https://pastecode.io/s/dgnjw0z9
输出apt-cache policy
:https://pastecode.io/s/w5rso9um
EDIT4:我尝试了一下
sudo dpkg --configure -a
sudo apt-get install -f
,得到了和给出的一样的错误apt-get install terminator
。最后两行是:
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
EDIT5:突然我的 gnome-terminal 开始工作了。但是 nautilis 仍然不工作。运行推荐的命令后:
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
cd ~/Downloads
apt-get download python3-minimal
dpkg -l | grep ^ii | grep python
sudo -E dpkg -i --force-all ./python3-minimal*.deb
sudo -E dpkg --configure -a
sudo -E apt-get install -f
sudo -E apt-get install --reinstall python3-minimal
sudo -E apt-get install --reinstall $(dpkg -l | grep ^ii | grep python | awk '{print $2}')
sudo -E dpkg --configure -a
sudo -E apt-get install -f
sudo -E apt-get install aptitude
sudo -E aptitude safe-upgrade
sudo -E aptitude dist-upgrade
输出为:https://pastecode.io/s/ytobvrny 仍然出现与上述相同的错误。
EDIT6:我刚刚在您的帖子之前尝试了一些方法,删除了 nvidia 驱动程序。之后我的 gui 消失了。然后我删除了 windows(它是双启动系统),我的 ttys 也消失了。我不记得我的密码了,所以几天都无法登录。现在我无法进入 grub,也许是为了尝试恢复模式。
我只是使用 live usb 并在 live usb 上恢复了 chrome。现在我该怎么办?是否可以通过 live usb 执行某些操作来再次恢复我安装的操作系统?在我的 gui 消失之前,我部分尝试了 @N0rbert 的答案,但我再次收到类似的错误。但没有完成安装所有下载的 deb。
答案1
请尝试N0berts 先回答
我建议在低级别重新安装可能有问题的软件包:export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" cd ~/Downloads apt-get download python3-minimal sudo -E dpkg -i --force-all ./python3-minimal*.deb sudo -E dpkg --configure -a sudo -E apt-get install -f sudo -E apt-get install --reinstall python3-minimal sudo -E apt-get install --reinstall $(dpkg -l | grep ^ii | grep python | awk '{print $2}') sudo -E dpkg --configure -a sudo -E apt-get install -f sudo -E apt-get install aptitude sudo -E aptitude safe-upgrade sudo -E aptitude dist-upgrade
尝试分别修复每个包:
mkdir ~/Downloads/debs cd ~/Downloads/debs apt-get download devhelp dput gdebi-core python3 python3-psutil apport python3-tz python3-apport python3-cupshelpers python3-monotonic python3-requests-unixsocket python3-six python3-simplejson python3-cups python3-oauthlib python3-chardet python3-configobj python3-secretstorage system-config-printer python3-certifi python3-pexpect python3-cryptography python3-wadllib python3-gi python3-requests python3-ldb python3-idna python3-fasteners python3-urllib3 gnome-shell ubuntu-session ibus gdm3 python3-defer duplicity python3-keyring python3-httplib2 language-selector-common python3-paramiko lsb-release python3-protobuf python3-future python3-rfc3339 python3-macaroonbakery python3-aptdaemon.gtk3widgets python3-ibus-1.0 python3-lazr.restfulclient python3-gi-cairo python3-lib2to3 terminator python3-nacl python3-systemd python3-cffi-backend sudo dpkg -i --force-all ./devhelp*.deb sudo dpkg -i --force-all ./dput*.deb sudo dpkg -i --force-all ./gdebi-core*.deb sudo dpkg -i --force-all ./python3*.deb sudo dpkg -i --force-all ./python3-psutil*.deb sudo dpkg -i --force-all ./apport*.deb sudo dpkg -i --force-all ./python3-tz*.deb sudo dpkg -i --force-all ./python3-apport*.deb sudo dpkg -i --force-all ./python3-cupshelpers*.deb sudo dpkg -i --force-all ./python3-monotonic*.deb sudo dpkg -i --force-all ./python3-requests-unixsocket*.deb sudo dpkg -i --force-all ./python3-six*.deb sudo dpkg -i --force-all ./python3-simplejson*.deb sudo dpkg -i --force-all ./python3-cups*.deb sudo dpkg -i --force-all ./python3-oauthlib*.deb sudo dpkg -i --force-all ./python3-chardet*.deb sudo dpkg -i --force-all ./python3-configobj*.deb sudo dpkg -i --force-all ./python3-secretstorage*.deb sudo dpkg -i --force-all ./system-config-printer*.deb sudo dpkg -i --force-all ./python3-certifi*.deb sudo dpkg -i --force-all ./python3-pexpect*.deb sudo dpkg -i --force-all ./python3-cryptography*.deb sudo dpkg -i --force-all ./python3-wadllib*.deb sudo dpkg -i --force-all ./python3-gi*.deb sudo dpkg -i --force-all ./python3-requests*.deb sudo dpkg -i --force-all ./python3-ldb*.deb sudo dpkg -i --force-all ./python3-idna*.deb sudo dpkg -i --force-all ./python3-fasteners*.deb sudo dpkg -i --force-all ./python3-urllib3*.deb sudo dpkg -i --force-all ./gnome-shell*.deb sudo dpkg -i --force-all ./ubuntu-session*.deb sudo dpkg -i --force-all ./ibus*.deb sudo dpkg -i --force-all ./gdm3*.deb sudo dpkg -i --force-all ./python3-defer*.deb sudo dpkg -i --force-all ./duplicity*.deb sudo dpkg -i --force-all ./python3-keyring*.deb sudo dpkg -i --force-all ./python3-httplib2*.deb sudo dpkg -i --force-all ./language-selector-common*.deb sudo dpkg -i --force-all ./python3-paramiko*.deb sudo dpkg -i --force-all ./lsb-release*.deb sudo dpkg -i --force-all ./python3-protobuf*.deb sudo dpkg -i --force-all ./python3-future*.deb sudo dpkg -i --force-all ./python3-rfc3339*.deb sudo dpkg -i --force-all ./python3-macaroonbakery*.deb sudo dpkg -i --force-all ./python3-aptdaemon.gtk3widgets*.deb sudo dpkg -i --force-all ./python3-ibus-1.0*.deb sudo dpkg -i --force-all ./python3-lazr.restfulclient*.deb sudo dpkg -i --force-all ./python3-gi-cairo*.deb sudo dpkg -i --force-all ./python3-lib2to3*.deb sudo dpkg -i --force-all ./terminator*.deb sudo dpkg -i --force-all ./python3-nacl*.deb sudo dpkg -i --force-all ./python3-systemd*.deb sudo dpkg -i --force-all ./python3-cffi-backend sudo apt-get install --reinstall devhelp dput gdebi-core python3 python3-psutil apport python3-tz python3-apport python3-cupshelpers python3-monotonic python3-requests-unixsocket python3-six python3-simplejson python3-cups python3-oauthlib python3-chardet python3-configobj python3-secretstorage system-config-printer python3-certifi python3-pexpect python3-cryptography python3-wadllib python3-gi python3-requests python3-ldb python3-idna python3-fasteners python3-urllib3 gnome-shell ubuntu-session ibus gdm3 python3-defer duplicity python3-keyring python3-httplib2 language-selector-common python3-paramiko lsb-release python3-protobuf python3-future python3-rfc3339 python3-macaroonbakery python3-aptdaemon.gtk3widgets python3-ibus-1.0 python3-lazr.restfulclient python3-gi-cairo python3-lib2to3 terminator python3-nacl python3-systemd python3-cffi-backend
然后从较小的代码块重复上述命令。
如果 N0berts 的回答不起作用,那么很抱歉,您需要继续执行危险命令或完全重新安装
在运行以下命令之前,请执行以下操作(这是可选的,但我们不要冒险) -
安装 ubuntu iso 文件
验证(可选)
将 iso 刻录到 cd-dvd-usb 等。
备份 /home
完毕
请不要做不该做的事情而破坏您的系统,如果您不明白任何事情,请询问,我很确定大多数命令都会超出您的理解范围,所以请随意询问任何事情。
首先运行
sudo apt --fix-broken install
运行上述命令后,尝试再次安装 aptitude
sudo apt -f install aptitude
让我们看看这是否有效
如果这不起作用,请尝试运行此
sudo rm -rf /var/cache/apt/archives/*.deb
此后,再次尝试安装 aptitude
如果错误仍然存在,那么就没有友好的解决方案了,但你需要强制删除所有问题包
怎么做
查看错误信息
Errors were encountered while processing:
python3
python3-psutil
apport
python3-tz
python3-apport
python3-cupshelpers
python3-monotonic
python3-requests-unixsocket
python3-six
python3-simplejson
python3-cups
python3-oauthlib
python3-chardet
python3-configobj
python3-secretstorage
system-config-printer
python3-certifi
python3-pexpect
python3-cryptography
python3-wadllib
python3-gi
python3-requests
python3-ldb
python3-idna
python3-fasteners
python3-urllib3
gnome-shell
ubuntu-session
ibus
gdm3
python3-defer
duplicity
python3-keyring
python3-httplib2
language-selector-common
python3-paramiko
lsb-release
python3-protobuf
python3-future
python3-rfc3339
python3-macaroonbakery
python3-aptdaemon.gtk3widgets
python3-ibus-1.0
python3-lazr.restfulclient
python3-gi-cairo
python3-lib2to3
terminator
python3-nacl
python3-systemd
python3-cffi-backend
Processing was halted because there were too many errors.
因此,要修复它,您需要手动将其从数据库中删除
如何
在启动徽标出现之前按下 Shift 键,在 grub 恢复模式下执行所有操作,然后选择 ubuntu 的高级选项 > 恢复模式 > 进入 root shell // 或者先打开 TTY 运行以下命令,然后按 ,ctrl + alt + f5
使用您的(sudo)用户名和密码登录
转到 /var/lib/dpkg/info
cd /var/lib/dpkg/info/
现在,正如我们看到上述错误,我们需要删除问题包
看到这一行
errors were encountered during processing
这意味着在这行之后的所有内容都只是一个包名称
所以第一个包是“python3”
sudo mv python3* $HOME
### WARNING DON'T CLOSE THE SHELL DON'T DO ANYTHING AFTER THAT
嘿,听着,我们不会删除文件,只是将它们移动到其他位置,所以,如果发生任何不好的事情,我们仍然可以修复它,因为我们有备份
然后再次测试
sudo apt -f install aptitude
再次查看错误消息(此后大多数错误都消失了)
然后对所有错误包再次执行相同操作(sudo mv error-package* $HOME
)
完成上述所有操作后,你将看到可以安装和使用 apt 包
现在修复所有复制/粘贴此行(如果您正在尝试,则需要手动输入此行)
for package in $(apt-get upgrade 2>&1 | grep "warning: files list file for package '" | grep -Po "[^'\n ]+'" | grep -Po "[^']+"); do apt-get install --reinstall "$package"; done
如果运行后没有返回任何内容sudo apt install python3-all
,你仍然会收到一条错误消息,指出缺少包 x 的文件,不要理会该错误
最后无论发生什么,您都需要运行这些命令。
确保运行-
sudo apt install python3-all
sudo apt install aptitude
sudo aptitude -f upgrade
sudo aptitude -f install --reinstall ubuntu-session
sudo reboot
现在你的问题越来越不应该被解决了
答案2
我建议在低级别重新安装可能有问题的软件包:
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
cd ~/Downloads
apt-get download python3-minimal
sudo -E dpkg -i --force-all ./python3-minimal*.deb
sudo -E dpkg --configure -a
sudo -E apt-get install -f
sudo -E apt-get install --reinstall python3-minimal
sudo -E apt-get install --reinstall $(dpkg -l | grep ^ii | grep python | awk '{print $2}')
sudo -E dpkg --configure -a
sudo -E apt-get install -f
sudo -E apt-get install aptitude
sudo -E aptitude safe-upgrade
sudo -E aptitude dist-upgrade
尝试分别修复每个包:
mkdir ~/Downloads/debs
cd ~/Downloads/debs
apt-get download devhelp dput gdebi-core python3 python3-psutil apport python3-tz python3-apport python3-cupshelpers python3-monotonic python3-requests-unixsocket python3-six python3-simplejson python3-cups python3-oauthlib python3-chardet python3-configobj python3-secretstorage system-config-printer python3-certifi python3-pexpect python3-cryptography python3-wadllib python3-gi python3-requests python3-ldb python3-idna python3-fasteners python3-urllib3 gnome-shell ubuntu-session ibus gdm3 python3-defer duplicity python3-keyring python3-httplib2 language-selector-common python3-paramiko lsb-release python3-protobuf python3-future python3-rfc3339 python3-macaroonbakery python3-aptdaemon.gtk3widgets python3-ibus-1.0 python3-lazr.restfulclient python3-gi-cairo python3-lib2to3 terminator python3-nacl python3-systemd python3-cffi-backend
sudo dpkg -i --force-all ./devhelp*.deb
sudo dpkg -i --force-all ./dput*.deb
sudo dpkg -i --force-all ./gdebi-core*.deb
sudo dpkg -i --force-all ./python3*.deb
sudo dpkg -i --force-all ./python3-psutil*.deb
sudo dpkg -i --force-all ./apport*.deb
sudo dpkg -i --force-all ./python3-tz*.deb
sudo dpkg -i --force-all ./python3-apport*.deb
sudo dpkg -i --force-all ./python3-cupshelpers*.deb
sudo dpkg -i --force-all ./python3-monotonic*.deb
sudo dpkg -i --force-all ./python3-requests-unixsocket*.deb
sudo dpkg -i --force-all ./python3-six*.deb
sudo dpkg -i --force-all ./python3-simplejson*.deb
sudo dpkg -i --force-all ./python3-cups*.deb
sudo dpkg -i --force-all ./python3-oauthlib*.deb
sudo dpkg -i --force-all ./python3-chardet*.deb
sudo dpkg -i --force-all ./python3-configobj*.deb
sudo dpkg -i --force-all ./python3-secretstorage*.deb
sudo dpkg -i --force-all ./system-config-printer*.deb
sudo dpkg -i --force-all ./python3-certifi*.deb
sudo dpkg -i --force-all ./python3-pexpect*.deb
sudo dpkg -i --force-all ./python3-cryptography*.deb
sudo dpkg -i --force-all ./python3-wadllib*.deb
sudo dpkg -i --force-all ./python3-gi*.deb
sudo dpkg -i --force-all ./python3-requests*.deb
sudo dpkg -i --force-all ./python3-ldb*.deb
sudo dpkg -i --force-all ./python3-idna*.deb
sudo dpkg -i --force-all ./python3-fasteners*.deb
sudo dpkg -i --force-all ./python3-urllib3*.deb
sudo dpkg -i --force-all ./gnome-shell*.deb
sudo dpkg -i --force-all ./ubuntu-session*.deb
sudo dpkg -i --force-all ./ibus*.deb
sudo dpkg -i --force-all ./gdm3*.deb
sudo dpkg -i --force-all ./python3-defer*.deb
sudo dpkg -i --force-all ./duplicity*.deb
sudo dpkg -i --force-all ./python3-keyring*.deb
sudo dpkg -i --force-all ./python3-httplib2*.deb
sudo dpkg -i --force-all ./language-selector-common*.deb
sudo dpkg -i --force-all ./python3-paramiko*.deb
sudo dpkg -i --force-all ./lsb-release*.deb
sudo dpkg -i --force-all ./python3-protobuf*.deb
sudo dpkg -i --force-all ./python3-future*.deb
sudo dpkg -i --force-all ./python3-rfc3339*.deb
sudo dpkg -i --force-all ./python3-macaroonbakery*.deb
sudo dpkg -i --force-all ./python3-aptdaemon.gtk3widgets*.deb
sudo dpkg -i --force-all ./python3-ibus-1.0*.deb
sudo dpkg -i --force-all ./python3-lazr.restfulclient*.deb
sudo dpkg -i --force-all ./python3-gi-cairo*.deb
sudo dpkg -i --force-all ./python3-lib2to3*.deb
sudo dpkg -i --force-all ./terminator*.deb
sudo dpkg -i --force-all ./python3-nacl*.deb
sudo dpkg -i --force-all ./python3-systemd*.deb
sudo dpkg -i --force-all ./python3-cffi-backend
sudo apt-get install --reinstall devhelp dput gdebi-core python3 python3-psutil apport python3-tz python3-apport python3-cupshelpers python3-monotonic python3-requests-unixsocket python3-six python3-simplejson python3-cups python3-oauthlib python3-chardet python3-configobj python3-secretstorage system-config-printer python3-certifi python3-pexpect python3-cryptography python3-wadllib python3-gi python3-requests python3-ldb python3-idna python3-fasteners python3-urllib3 gnome-shell ubuntu-session ibus gdm3 python3-defer duplicity python3-keyring python3-httplib2 language-selector-common python3-paramiko lsb-release python3-protobuf python3-future python3-rfc3339 python3-macaroonbakery python3-aptdaemon.gtk3widgets python3-ibus-1.0 python3-lazr.restfulclient python3-gi-cairo python3-lib2to3 terminator python3-nacl python3-systemd python3-cffi-backend
然后从较小的代码块重复上述命令。
不要尝试删除文件/var/lib/dpkg/info/
- 这是很危险的,并且可能会使情况变得更糟,直到完全重新安装。