更新 Ubuntu 20.04 时,出现以下错误:
Errors were encountered while processing:
/var/cache/apt/archives/libsystemd0_245.4-4ubuntu3.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
该系统运行的是 19.10,最近升级到 20.04。
其结果sudo apt autoremove
是:
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:
libsystemd0 : Breaks: libsystemd0:i386 (!= 245.4-4ubuntu3.1) but 245.4-4ubuntu3.2 is installed
libsystemd0:i386 : Breaks: libsystemd0 (!= 245.4-4ubuntu3.2) but 245.4-4ubuntu3.1 is installed
libudev1 : Breaks: libudev1:i386 (!= 245.4-4ubuntu3.1) but 245.4-4ubuntu3.2 is installed
libudev1:i386 : Breaks: libudev1 (!= 245.4-4ubuntu3.2) but 245.4-4ubuntu3.1 is installed
systemd : Depends: libsystemd0 (= 245.4-4ubuntu3.2) but 245.4-4ubuntu3.1 is installed
udev : Depends: libudev1 (= 245.4-4ubuntu3.2) but 245.4-4ubuntu3.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
其结果sudo apt install libsystemd0
是:
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:
libudev1 : Breaks: libudev1:i386 (!= 245.4-4ubuntu3.1) but 245.4-4ubuntu3.2 is to be installed
libudev1:i386 : Breaks: libudev1 (!= 245.4-4ubuntu3.2) but 245.4-4ubuntu3.1 is to be installed
udev : Depends: libudev1 (= 245.4-4ubuntu3.2) but 245.4-4ubuntu3.1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
答案1
如果你在软件 sources.list 中添加了导致大量版本冲突的 PPA,请删除它们,然后使用以下命令恢复 Ubuntu 的默认软件存储库:如何恢复默认存储库?.然后使用 更新软件源sudo apt update
。
删除生成错误消息的缓存 libsystemd0 .deb 文件并重新安装 libsystemd0 和 libudev1。
sudo rm /var/cache/apt/archives/libsystemd0_245.4-4ubuntu3.2_amd64.deb # If this command results in a warning ignore the warning.
sudo apt update # try to update again
sudo apt autoremove
sudo apt remove libsystemd0:i386 libudev1:i386 libsystemd0 libudev1
sudo apt --fix-broken install
sudo apt install libsystemd0 libudev1