我刚刚安装了 Ubuntu Gnome 16.04。我告诉它保存我的文件 - 这很有效。有些软件必须重新安装。现在,当我运行时,sudo apt-get update
我看到了:
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (restricted/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (multiverse/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (multiverse/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (multiverse/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11 (multiverse/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11-icons (multiverse/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: The repository 'http://extras.ubuntu.com/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: http://dl.google.com/linux/chrome/deb/dists/stable/Release.gpg: Signature by key 4CCA1EAF950CEE4AB83976DCA040830F7FAC5991 uses weak digest algorithm (SHA1)
W: http://repo.sinew.in/dists/stable/InRelease: Signature by key B6DA722E2E65721AF54B93966F7565879798C2FC uses weak digest algorithm (SHA1)
E: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/xenial/main/source/Sources 404 Not Found [IP: 91.189.92.152 80]
E: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found [IP: 91.189.92.152 80]
E: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/xenial/main/binary-i386/Packages 404 Not Found [IP: 91.189.92.152 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (restricted/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (multiverse/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (multiverse/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target Translations (multiverse/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11 (multiverse/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
W: Target DEP-11-icons (multiverse/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87
有没有一种自动化的方法来解决这个问题?
最近的最新解决方案
我编写了一个 Python 脚本来自动执行此任务。您可以在此处找到最新版本。
安装:
安装先决条件:
从最新版本下载 PYZ 包 (
aptsources-cleanup.pyz
) 。将 PYZ 捆绑包标记为可执行文件:
用法:
从 PYZ 包的下载位置(参见上面的步骤 2)运行:
按照屏幕上显示的说明进行操作。
如果您想报告问题、发表评论或 fork 源代码,请在 GitHub 上进行。
历史过时的解决方案
这是一个更旧、更短、更简单的版本,更适合内联引用:
它不带任何参数,并且
/etc/apt/sources.list*
在包的帮助下适用于所有功能python3-apt
。行不必完全重复(即使在规范化之后),但如果类型、URI、套件和至少一个组件重叠就足够了。我不确定相等测试在所有极端情况下是否正确(例如各种“选项”字符串)。
对我来说(16.04 LTS)去
系统设置>>软件和更新>>其他软件并从列表中删除每个重复条目工作正常。
像这样重置您的存储库:
software-properties-gtk
安装(您可以运行software-properties-gtk -h
以验证您是否收到帮助消息)sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo software-properties-gtk
一切正常后,您可以使用
sudo rm -rf /etc/apt/sources.list.bak
.由于错误告诉您问题出在哪里,并且所有问题都是由于单个重复行造成的,因此您可以使用 vim、nano 等文本编辑器轻松手动修复此问题。这样做的一个好处是您可以准确地看到问题是什么,你正在做什么来解决它。
在您的情况下,使用 sudo 或以 root 身份在文本编辑器中打开 /etc/apt/sources.list 。删除第 33 行或第 87 行。您可以先目视检查它们是否重复。
如果你喜欢 vi...
或者,如果你犯了错误,就退出......
对于带有 Linux mint 的基于 Ubuntu 的系统,请转到Software Sources > Maintenance > Remove Duplicate packages
类似于其他答案,但是...
我不得不查看/etc/apt/sources.list.d。该目录中的两个列表文件试图引用相同的内容。
我保留了引用更多内容的列表文件。问题解决了。
手动编辑 /etc/apt/sources.list 并删除重复的行。
对于您无法控制的 Ubuntu 安装程序问题,我认为这不是一个有用的建议。但是,如果您只是在自己编写一些安装命令后遇到此错误,这可能会有所帮助:
在一个 python2 ROS 项目的 Dockerfile 和很多安装
apt-get
包之前的错误,我首先得到了另一个错误:/bin/sh: 1: python-matplotlib: not found
,虽然它是apt-get
. 然后我切换到python -m pip install -y matplotlib sympy
哪个导致问题的错误:#13 3.422 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/ros-latest.list:1 and /etc/apt/sources.list.d/ros1-latest.list:1
. 此时,您也可以考虑python2.7 -m pip install -y matplotlib sympy
根据this进行测试。然后我切换回apt-get
我也将这条线与其他装置分开。这些步骤可能并非全部都需要,我只是不想取出任何步骤,因为我只能猜测原因。最终工作的 Dockerfile 的一小部分:
更新:运行时我再次
update
遇到错误。我只是放弃了更新。这很有效,因为它之前已经运行了几行:从:
至