修复Ubuntu中的“遇到没有包的部分:标头”错误

今天,当我尝试更新Ubuntu 20.04 LTS桌面系统时遇到以下错误。

$ sudo apt update

样本输出:

Get:1 http://ny-mirrors.evowise.com/ubuntu focal InRelease [265 kB]
Hit:2 http://linux.teamviewer.com/deb stable InRelease                                                                                                                   
Hit:3 http://ppa.launchpad.net/costales/yaru-colors-folder-color/ubuntu focal InRelease
Hit:4 http://ny-mirrors.evowise.com/ubuntu focal-updates InRelease  
Hit:5 http://ny-mirrors.evowise.com/ubuntu focal-backports InRelease
Hit:6 http://ny-mirrors.evowise.com/ubuntu focal-security InRelease
Hit:7 http://dl.google.com/linux/chrome/deb stable InRelease
Fetched 265 kB in 3s (99.8 kB/s)
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

我再次尝试使用Graphical Synaptic软件包管理器。 但是没有运气! 我遇到了同样的错误!

在Ubuntu中遇到没有Package:header错误的部分

这是基于Ubuntu和Debian的系统中的常见问题之一。

仔细阅读输出后,我了解到软件包列表或状态文件由于某种原因而损坏,因此无法对其进行解析。 对于那些想知道的人,状态文件包含有关已安装的deb软件包的信息。 我们可以通过删除损坏的软件包列表和状态文件并按如下所述重新生成它们来解决此问题。

在Ubuntu中修复“遇到没有包的部分:标头”错误

首先,使用以下命令删除损坏的软件包列表:

$ sudo rm /var/lib/apt/lists/* -vf

上面的命令将从Ubuntu系统中删除所有软件包源清单。

这是我的Ubuntu 20.04 LTS桌面的示例输出:

rm: cannot remove '/var/lib/apt/lists/auxfiles': Is a directory
removed '/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_InRelease'
removed '/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages'
removed '/var/lib/apt/lists/linux.teamviewer.com_deb_dists_stable_InRelease'
removed '/var/lib/apt/lists/linux.teamviewer.com_deb_dists_stable_main_binary-amd64_Packages'
removed '/var/lib/apt/lists/linux.teamviewer.com_deb_dists_stable_main_binary-i386_Packages'
removed '/var/lib/apt/lists/lock'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_Contents-amd64.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_Contents-i386.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_InRelease'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_main_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_multiverse_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_restricted_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-backports_universe_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_Contents-amd64.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_Contents-i386.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_InRelease'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_main_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_multiverse_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_restricted_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_restricted_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_restricted_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_restricted_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_Contents-amd64.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_Contents-i386.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_InRelease'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_main_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_multiverse_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_multiverse_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_multiverse_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_restricted_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_restricted_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_restricted_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_restricted_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-security_universe_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal_universe_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_Contents-amd64.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_Contents-i386.lz4'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_InRelease'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_main_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_multiverse_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_restricted_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_restricted_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_restricted_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_restricted_i18n_Translation-en'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_binary-amd64_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_binary-i386_Packages'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_cnf_Commands-amd64'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_dep11_Components-amd64.yml.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_dep11_icons-48x48.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_dep11_icons-64x64.tar.gz'
removed '/var/lib/apt/lists/ny-mirrors.evowise.com_ubuntu_dists_focal-updates_universe_i18n_Translation-en'
rm: cannot remove '/var/lib/apt/lists/partial': Is a directory
removed '/var/lib/apt/lists/ppa.launchpad.net_costales_yaru-colors-folder-color_ubuntu_dists_focal_InRelease'
removed '/var/lib/apt/lists/ppa.launchpad.net_costales_yaru-colors-folder-color_ubuntu_dists_focal_main_binary-amd64_Packages'
removed '/var/lib/apt/lists/ppa.launchpad.net_costales_yaru-colors-folder-color_ubuntu_dists_focal_main_binary-i386_Packages'
removed '/var/lib/apt/lists/ppa.launchpad.net_costales_yaru-colors-folder-color_ubuntu_dists_focal_main_i18n_Translation-en'

现在,运行以下命令来重建软件包源清单:

$ sudo apt update

这将需要一段时间,具体取决于您的Internet速度。 耐心一点!

重新生成软件包清单后,请一一运行以下命令以进行全面更新:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade

更新Ubuntu系统后,清除软件包缓存:

$ sudo apt autoclean
$ sudo apt autoremove

最后,关闭所有打开的程序并重新启动系统:

$ sudo reboot

该问题现在应该消失了。

万一您仍然看到相同的错误,请删除状态文件并使用以下命令重建它:

$ sudo rm /var/lib/dpkg/status
$ sudo touch /var/lib/dpkg/status
$ sudo apt update

不要忘记执行完整的系统更新并清理apt缓存,然后重新启动系统。

希望这可以帮助。

Ubuntu中的其他常见问题:

  • 如何在不重新安装的情况下修复损坏的Ubuntu OS
  • 如何在Ubuntu上修复Busybox Initramfs错误
  • 在Ubuntu中修复“子进程/ usr / bin / dpkg返回错误代码(1)”
  • 修复“ W:某些索引文件下载失败。” Ubuntu中的错误
  • 修复“ E:软件包缓存文件已损坏,哈希值错误”在Ubuntu中出现错误
  • 如何修复“ E:在Ubuntu上无法获取锁/ var / lib / dpkg / lock”错误
  • 在Ubuntu中修复“ dpkg:错误:解析文件’/ var / lib / dpkg / updates / 0014’”错误

APTDebianLinuxLinux命令Linux故障排除

Sidebar