修复“sudo apt --fix-broken install”“sudo apt remove libc6:amd64”“sudo dpkg --configure -a”无法在 Ubuntu20.04 中删除软件包

修复“sudo apt --fix-broken install”“sudo apt remove libc6:amd64”“sudo dpkg --configure -a”无法在 Ubuntu20.04 中删除软件包

结论:感谢所有帮助我解决这个问题的人。现在我已经尝试了几乎所有相关方法,但仍然无法弄清楚。

所以我打算重新安装整个系统。

PS:永远不要停止处理程序,否则你会遇到和我一样的问题。


问题:

我实际上尝试了很多方法但仍然没有找到答案。有人能帮助我吗?

我的系统是 Ubuntu 20.04,当我运行下面的代码时

sudo apt --fix-broken install

我收到一条错误消息

Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libopencc2 libopencc2-data
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  locales
The following NEW packages will be installed
  locales
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
3 not fully installed or removed.
Need to get 0 B/6,592 kB of archives.
After this operation, 17.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
dpkg: error processing package libc6:amd64 (--configure):
 package libc6:amd64 is not ready for configuration
 cannot configure (current status 'half-installed')
Errors were encountered while processing:
 libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

我试图删除

sudo apt remove libc6:amd64

我得到了

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 accountsservice : Depends: libc6 (>= 2.4) but it is not going to be installed
 acl : Depends: libc6 (>= 2.14) but it is not going to be installed
 acpid : Depends: libc6 (>= 2.27) but it is not going to be installed
 activity-log-manager : Depends: libc6 (>= 2.4) but it is not going to be installed
 alsa-utils : Depends: libc6 (>= 2.29) but it is not going to be installed
 anacron : Depends: libc6 (>= 2.7) but it is not going to be installed
 apg : Depends: libc6 (>= 2.14) but it is not going to be installed
 apparmor : Depends: libc6 (>= 2.17) but it is not going to be installed
 appstream : Depends: libc6 (>= 2.4) but it is not going to be installed
 apt : Depends: libc6 (>= 2.15) but it is not going to be installed
 apt-utils : Depends: libc6 (>= 2.14) but it is not going to be installed
 aspell : Depends: libc6 (>= 2.14) but it is not going to be installed
 at-spi2-core : Depends: libc6 (>= 2.7) but it is not going to be installed
 avahi-autoipd : Depends: libc6 (>= 2.14) but it is not going to be installed
 avahi-daemon : Depends: libc6 (>= 2.27) but it is not going to be installed
 avahi-utils : Depends: libc6 (>= 2.4) but it is not going to be installed
 bamfdaemon : Depends: libc6 (>= 2.14) but it is not going to be installed
 baobab : Depends: libc6 (>= 2.4) but it is not going to be installed
 base-files : Depends: libc6 (>= 2.3.4) but it is not going to be installed
 base-passwd : Depends: libc6 (>= 2.8) but it is not going to be installed
 bash : PreDepends: libc6 (>= 2.15) but it is not going to be installed
 bc : Depends: libc6 (>= 2.14) but it is not going to be installed
 bind9-dnsutils : Depends: libc6 (>= 2.4) but it is not going to be installed
 bind9-host : Depends: libc6 (>= 2.4) but it is not going to be installed
 bind9-libs : Depends: libc6 (>= 2.17) but it is not going to be installed
 binutils-x86-64-linux-gnu : Depends: libc6 (>= 2.27) but it is not going to be installed
 blender : Depends: libc6 (>= 2.29) but it is not going to be installed
 bluez : Depends: libc6 (>= 2.17) but it is not going to be installed
 bluez-cups : Depends: libc6 (>= 2.15) but it is not going to be installed
 bluez-obexd : Depends: libc6 (>= 2.28) but it is not going to be installed
 bolt : Depends: libc6 (>= 2.28) but it is not going to be installed
 brightnessctl : Depends: libc6 (>= 2.27) but it is not going to be installed
 brltty : Depends: libc6 (>= 2.27) but it is not going to be installed
 bsdmainutils : Depends: libc6 (>= 2.14) but it is not going to be installed
 bsdutils : PreDepends: libc6 (>= 2.17) but it is not going to be installed
 bubblewrap : Depends: libc6 (>= 2.16) but it is not going to be installed
 busybox-initramfs : Depends: libc6 (>= 2.28) but it is not going to be installed
 bzip2 : Depends: libc6 (>= 2.14) but it is not going to be installed
 cheese : Depends: libc6 (>= 2.4) but it is not going to be installed
 colord : Depends: libc6 (>= 2.29) but it is not going to be installed
 compiz-core : Depends: libc6 (>= 2.14) but it is not going to be installed
 compiz-gnome : Depends: libc6 (>= 2.7) but it is not going to be installed
 compiz-plugins-default : Depends: libc6 (>= 2.29) but it is not going to be installed
 copyq : Depends: libc6 (>= 2.14) but it is not going to be installed
 coreutils : PreDepends: libc6 (>= 2.28) but it is not going to be installed
 cpio : Depends: libc6 (>= 2.17) but it is not going to be installed
 cpp-9 : Depends: libc6 (>= 2.14) but it is not going to be installed
 cracklib-runtime : Depends: libc6 (>= 2.4) but it is not going to be installed
 crda : Depends: libc6 (>= 2.7) but it is not going to be installed
 cron : Depends: libc6 (>= 2.7) but it is not going to be installed
 cups : Depends: libc6 (>= 2.16) but it is not going to be installed
 cups-browsed : Depends: libc6 (>= 2.7) but it is not going to be installed
 cups-bsd : Depends: libc6 (>= 2.4) but it is not going to be installed
 cups-client : Depends: libc6 (>= 2.7) but it is not going to be installed
 cups-core-drivers : Depends: libc6 (>= 2.7) but it is not going to be installed
 cups-daemon : Depends: libc6 (>= 2.15) but it is not going to be installed
 cups-filters : Depends: libc6 (>= 2.29) but it is not going to be installed
 cups-filters-core-drivers : Depends: libc6 (>= 2.14) but it is not going to be installed
...TOO LONG SO I JUST CUT THE START AND THE END...
 xserver-xorg-video-qxl : Depends: libc6 (>= 2.14) but it is not going to be installed
 xserver-xorg-video-radeon : Depends: libc6 (>= 2.17) but it is not going to be installed
 xserver-xorg-video-vesa : Depends: libc6 (>= 2.14) but it is not going to be installed
 xserver-xorg-video-vmware : Depends: libc6 (>= 2.14) but it is not going to be installed
 xwayland : Depends: libc6 (>= 2.29) but it is not going to be installed
 xxd : Depends: libc6 (>= 2.3.4) but it is not going to be installed
 xz-utils : Depends: libc6 (>= 2.17) but it is not going to be installed
 yelp : Depends: libc6 (>= 2.4) but it is not going to be installed
 zeitgeist-core : Depends: libc6 (>= 2.14) but it is not going to be installed
 zeitgeist-datahub : Depends: libc6 (>= 2.4) but it is not going to be installed
 zenity : Depends: libc6 (>= 2.4) but it is not going to be installed
 zip : Depends: libc6 (>= 2.14) but it is not going to be installed
 zlib1g : Depends: libc6 (>= 2.14) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

谁能帮我?

更新

当我跑步时

sudo apt install --reinstall libc6:amd64

我有

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 language-pack-en-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-gnome-en-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-gnome-zh-hans-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-zh-hans-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 libreoffice-l10n-en-gb : Depends: locales but it is not going to be installed or
                                   locales-all
 libreoffice-l10n-en-za : Depends: locales but it is not going to be installed or
                                   locales-all
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

然后我跑

sudo dpkg --configure -a

我有

dpkg: error processing package libc6:i386 (--configure):
 package libc6:i386 cannot be configured because libc6:amd64 is not ready (current status 'half-installed')
dpkg: dependency problems prevent configuration of libcrypt1:i386:
 libcrypt1:i386 depends on libc6 (>= 2.25); however:
  Package libc6:i386 is not configured yet.

dpkg: error processing package libcrypt1:i386 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent processing triggers for libc-bin:
 libc-bin depends on libc6 (>> 2.31); however:
  Package libc6:amd64 is not installed.
 libc-bin depends on libc6 (<< 2.32); however:
  Package libc6:amd64 is not installed.

dpkg: error processing package libc-bin (--configure):
 dependency problems - leaving triggers unprocessed
dpkg: dependency problems prevent processing triggers for man-db:
 man-db depends on libc6 (>= 2.28); however:
  Package libc6:amd64 is not installed.

dpkg: error processing package man-db (--configure):
 dependency problems - leaving triggers unprocessed
Errors were encountered while processing:
 libc6:i386
 libcrypt1:i386
 libc-bin
 man-db

当我尝试

sudo aptitude reinstall libc6:amd64

表明

sudo: aptitude: command not found

然后我尝试

sudo apt-get install aptitude

我有

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 aptitude : Depends: aptitude-common (= 0.8.12-1ubuntu4) but it is not going to be installed
            Depends: libcwidget4 (>= 0.5.18-1) but it is not going to be installed
            Recommends: libparse-debianchangelog-perl but it is not going to be installed
 language-pack-en-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-gnome-en-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-gnome-zh-hans-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-zh-hans-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 libreoffice-l10n-en-gb : Depends: locales but it is not going to be installed or
                                   locales-all
 libreoffice-l10n-en-za : Depends: locales but it is not going to be installed or
                                   locales-all
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

又一个循环。

更新

我试过

sudo apt update

我有

Hit:1 http://au.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://au.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]     
Get:3 http://au.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]   
Get:4 http://au.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,384 kB]
Hit:5 https://typora.io ./linux/ InRelease                                     
Hit:6 https://typora.io/linux ./ InRelease                                     
Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease                  
Get:8 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]      
Hit:9 http://ppa.launchpad.net/hluk/copyq/ubuntu focal InRelease               
Get:10 http://au.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [788 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [59.9 kB]
Get:13 http://au.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [274 kB]
Get:14 http://au.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [712 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [94.1 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [940 B]
Get:17 http://au.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,026 kB]
Get:18 http://au.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [408 kB]
Get:19 http://au.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [23.6 kB]
Get:20 http://au.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [940 B]
Get:21 http://au.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [8,000 B]
Get:22 http://au.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB]
Hit:12 https://archive.ubuntukylin.com/ukui focal InRelease                    
Fetched 6,146 kB in 5s (1,359 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up-to-date.
W: Conflicting distribution: https://typora.io ./linux/ InRelease (expected ./linux/ but got )

然后我尝试

grep -r deb /etc/apt/sources.list /etc/apt/sources.list.d/

我有

/etc/apt/sources.list:# deb cdrom:[Ubuntu 20.04.5 LTS _Focal Fossa_ - Release amd64 (20220831)]/ focal main restricted
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal main restricted
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal main restricted
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal-updates main restricted
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal-updates main restricted
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal universe
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal universe
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal-updates universe
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal-updates universe
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal multiverse
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal multiverse
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal-updates multiverse
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal-updates multiverse
/etc/apt/sources.list:deb http://au.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
/etc/apt/sources.list:# deb-src http://au.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
/etc/apt/sources.list:# deb http://archive.canonical.com/ubuntu focal partner
/etc/apt/sources.list:# deb-src http://archive.canonical.com/ubuntu focal partner
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security main restricted
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security universe
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu focal-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list:# (e.g. netinst, live or single CD). The matching "deb cdrom"
/etc/apt/sources.list:deb https://typora.io ./linux/
/etc/apt/sources.list:# deb-src https://typora.io ./linux/
/etc/apt/sources.list:deb https://typora.io/linux ./
/etc/apt/sources.list:# deb-src https://typora.io/linux ./
/etc/apt/sources.list:deb http://archive.ubuntukylin.com/ukui focal main
/etc/apt/sources.list:# deb-src http://archive.ubuntukylin.com/ukui focal main
/etc/apt/sources.list.d/hluk-ubuntu-copyq-focal.list.save:deb http://ppa.launchpad.net/hluk/copyq/ubuntu focal main
/etc/apt/sources.list.d/hluk-ubuntu-copyq-focal.list.save:# deb-src http://ppa.launchpad.net/hluk/copyq/ubuntu focal main
/etc/apt/sources.list.d/google-chrome.list:deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
/etc/apt/sources.list.d/hluk-ubuntu-copyq-focal.list:deb http://ppa.launchpad.net/hluk/copyq/ubuntu focal main
/etc/apt/sources.list.d/hluk-ubuntu-copyq-focal.list:# deb-src http://ppa.launchpad.net/hluk/copyq/ubuntu focal main
/etc/apt/sources.list.d/google-chrome.list.save:deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main

然后我尝试

apt-cache policy libc6:amd64 libc6:i386 libcrypt1:i386 libcrypt1:amd64

我有

libc6:
  Installed: 2.31-0ubuntu9.9
  Candidate: 2.31-0ubuntu9.9
  Version table:
 *** 2.31-0ubuntu9.9 500
        500 http://au.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.31-0ubuntu9.7 500
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     2.31-0ubuntu9 500
        500 http://au.archive.ubuntu.com/ubuntu focal/main amd64 Packages
libc6:i386:
  Installed: 2.31-0ubuntu9.9
  Candidate: 2.31-0ubuntu9.9
  Version table:
 *** 2.31-0ubuntu9.9 500
        500 http://au.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
        100 /var/lib/dpkg/status
     2.31-0ubuntu9.7 500
        500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
     2.31-0ubuntu9 500
        500 http://au.archive.ubuntu.com/ubuntu focal/main i386 Packages
libcrypt1:i386:
  Installed: 1:4.4.10-10ubuntu4
  Candidate: 1:4.4.10-10ubuntu4
  Version table:
 *** 1:4.4.10-10ubuntu4 500
        500 http://au.archive.ubuntu.com/ubuntu focal/main i386 Packages
        100 /var/lib/dpkg/status
libcrypt1:
  Installed: 1:4.4.10-10ubuntu4
  Candidate: 1:4.4.10-10ubuntu4
  Version table:
 *** 1:4.4.10-10ubuntu4 500
        500 http://au.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status

然后我尝试

sudo apt --fix-broken install

我有

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libopencc2 libopencc2-data
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  locales
The following NEW packages will be installed
  locales
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
3 not fully installed or removed.
Need to get 0 B/6,592 kB of archives.
After this operation, 17.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
dpkg: error processing package libc6:amd64 (--configure):
 package libc6:amd64 is not ready for configuration
 cannot configure (current status 'half-installed')
Errors were encountered while processing:
 libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

更新 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

我试过

sudo apt reinstall --fix-broken libc6:amd64
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 language-pack-en-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-gnome-en-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-gnome-zh-hans-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 language-pack-zh-hans-base : Depends: locales (>= 2.3.6) but it is not going to be installed
 libreoffice-l10n-en-gb : Depends: locales but it is not going to be installed or
                                   locales-all
 libreoffice-l10n-en-za : Depends: locales but it is not going to be installed or
                                   locales-all
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我试过

/etc/apt/sources.list

我有

bash: /etc/apt/sources.list: Permission denied

我试过

deb https://typora.io/linux ./

我有

Command 'deb' not found, did you mean:

  command 'den' from snap den (1.2.0-0)
  command 'dub' from snap dub (1.19.0)
  command 'edb' from deb edb-debugger (1.0.0-1build3)
  command 'dab' from deb bsdgames (2.17-28build1)
  command 'dub' from deb dub (1.19.0-1build2.1)
  command 'derb' from deb icu-devtools (66.1-2ubuntu2.1)
  command 'debi' from deb devscripts (2.20.2ubuntu2)
  command 'debc' from deb devscripts (2.20.2ubuntu2)
  command 'dex' from deb dex (0.8.0-2)
  command 'dep' from deb go-dep (0.5.4-3ubuntu0.1)
  command 'deb3' from deb quilt (0.65-3)

See 'snap info <snapname>' for additional versions.

我尝试编辑

/etc/apt/sources.list

我有

/etc/apt/sources.list: Permission denied

并且无法保存只读文件。

答案1

我在使用 apt 时也遇到了类似的问题。

我的解决方案正在运行sudo apt-get update

此后 apt 就可以正常工作了!

因此尝试此命令然后运行sudo apt --fix-broken install

答案2

我試一試。

/etc/apt/sources.list

变更条目

deb https://typora.io/linux ./

#deb https://typora.io/linux ./

apt 对此条目发出警告。然后从镜像服务器更改为主服务器

sudo sed -i s,//au.archive,//archive,g  /etc/apt/sources.list

现在我们让 apt 忘记镜像服务器上有哪些可用内容。

sudo rm -rf /var/lib/apt/lists/*

dpkg 也一样。

sudo dpkg --clear-avail

请与

sudo ls -al /var/cache/apt/archives/partial/

如果此文件夹为空。如果不是,则仅删除内容。

sudo rm /var/cache/apt/archives/partial/*

现在继续

sudo apt update && sudo apt -f install

旁注:对重要数据进行当前备份总是一个好主意。

相关内容