AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 760896
Accepted
Tim
Tim
Asked: 2016-04-23 14:20:11 +0800 CST2016-04-23 14:20:11 +0800 CST 2016-04-23 14:20:11 +0800 CST

如何修复 apt 错误“W:Target Packages ... 已配置多次”?

  • 772

我刚刚安装了 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

有没有一种自动化的方法来解决这个问题?

apt
  • 8 8 个回答
  • 331038 Views

8 个回答

  • Voted
  1. Best Answer
    David Foerster
    2016-04-26T16:35:49+08:002016-04-26T16:35:49+08:00

    最近的最新解决方案

    我编写了一个 Python 脚本来自动执行此任务。您可以在此处找到最新版本。

    安装:

    1. 安装先决条件:

      sudo apt install python3-apt
      
    2. 从最新版本下载 PYZ 包 ( aptsources-cleanup.pyz) 。

    3. 将 PYZ 捆绑包标记为可执行文件:

      chmod a+x aptsources-cleanup.pyz
      

    用法:

    1. 从 PYZ 包的下载位置(参见上面的步骤 2)运行:

      sudo ./aptsources-cleanup.pyz
      
    2. 按照屏幕上显示的说明进行操作。

    如果您想报告问题、发表评论或 fork 源代码,请在 GitHub 上进行。


    历史过时的解决方案

    这是一个更旧、更短、更简单的版本,更适合内联引用:

    #!/usr/bin/python3
    """
    Detects and interactively deactivates duplicate Apt source entries.
    
    Usage: sudo python3 apt-remove-duplicate-source-entries.py
    """
    
    from __future__ import print_function
    import aptsources.sourceslist
    
    EMPTY_COMPONENT_LIST = (None,)
    
    def get_duplicates(sourceslist):
        """
        Detects and returns duplicate Apt source entries.
        """
    
        sentry_map = dict()
        duplicates = list()
        for se in sourceslist.list:
            if not se.invalid and not se.disabled:
                for c in (se.comps or EMPTY_COMPONENT_LIST):
                    key = (se.type, se.uri, se.dist, c)
                    previous_se = sentry_map.setdefault(key, se)
                    if previous_se is not se:
                        duplicates.append((se, previous_se))
                        break
    
        return duplicates
    
    
    if __name__ == '__main__':
        try:
            input = raw_input
        except NameError:
            pass
    
        sourceslist = aptsources.sourceslist.SourcesList(False)
        duplicates = get_duplicates(sourceslist)
    
        if duplicates:
            for dupe, orig in duplicates:
                print(
                    'Overlapping source entries:\n'
                    '  1. {0}: {1}\n'
                    '  2. {2}: {3}\n'
                    'I disabled the latter entry.'.format(
                        orig.file, orig, dupe.file, dupe),
                    end='\n\n')
                dupe.disabled = True
    
            print('\n{0} source entries were disabled:'.format(len(duplicates)),
                *[dupe for dupe, orig in duplicates], sep='\n  ', end='\n\n')
            if input('Do you want to save these changes? (y/N) ').upper() == 'Y':
                sourceslist.save()
    
        else:
            print('No duplicated entries were found.')
    

    它不带任何参数,并且/etc/apt/sources.list*在包的帮助下适用于所有功能python3-apt。行不必完全重复(即使在规范化之后),但如果类型、URI、套件和至少一个组件重叠就足够了。

    我不确定相等测试在所有极端情况下是否正确(例如各种“选项”字符串)。

    • 311
  2. learner
    2016-11-07T02:50:52+08:002016-11-07T02:50:52+08:00

    对我来说(16.04 LTS)去

    系统设置>>软件和更新>>其他软件并从列表中删除每个重复条目工作正常。

    • 150
  3. Andrew
    2016-06-04T18:51:48+08:002016-06-04T18:51:48+08:00

    像这样重置您的存储库:

    1. 重要提示:首先验证您是否已software-properties-gtk安装(您可以运行software-properties-gtk -h以验证您是否收到帮助消息)
    2. sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
    3. sudo software-properties-gtk
    4. 选择你的选项
    5. 节省

    一切正常后,您可以使用sudo rm -rf /etc/apt/sources.list.bak.

    • 43
  4. mightypile
    2019-01-15T08:08:12+08:002019-01-15T08:08:12+08:00

    由于错误告诉您问题出在哪里,并且所有问题都是由于单个重复行造成的,因此您可以使用 vim、nano 等文本编辑器轻松手动修复此问题。这样做的一个好处是您可以准确地看到问题是什么,你正在做什么来解决它。

    在您的情况下,使用 sudo 或以 root 身份在文本编辑器中打开 /etc/apt/sources.list 。删除第 33 行或第 87 行。您可以先目视检查它们是否重复。

    如果你喜欢 vi...

    $ sudo vim /etc/apt/sources.list
    33 [Shift]+g    # to goto line 33
    87 [Shift]+g    # to goto line 87, don't need a duplicate of line 33
    dd              # to delete the line you're on
    :wq             # to write the file and quit
    

    或者,如果你犯了错误,就退出......

    :q!             # to quit without saving any changes
    
    • 31
  5. Mario Olivio Flores
    2019-01-31T02:37:16+08:002019-01-31T02:37:16+08:00

    对于带有 Linux mint 的基于 Ubuntu 的系统,请转到Software Sources > Maintenance > Remove Duplicate packages

    • 7
  6. Thom Ives
    2022-03-16T11:03:20+08:002022-03-16T11:03:20+08:00

    类似于其他答案,但是...

    我不得不查看/etc/apt/sources.list.d。该目录中的两个列表文件试图引用相同的内容。

    我保留了引用更多内容的列表文件。问题解决了。

    • 3
  7. logbasex
    2021-10-17T23:14:47+08:002021-10-17T23:14:47+08:00

    手动编辑 /etc/apt/sources.list 并删除重复的行。

    • 1
  8. questionto42standswithUkraine
    2021-03-21T09:39:45+08:002021-03-21T09:39:45+08:00

    对于您无法控制的 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 install -y python-matplotlib python-sympy
    

    apt-get我也将这条线与其他装置分开。

    这些步骤可能并非全部都需要,我只是不想取出任何步骤,因为我只能猜测原因。最终工作的 Dockerfile 的一小部分:

    RUN apt-get install --upgrade python-pip -y && \
        python -m pip install --upgrade pip
    # I have seen during installation that the default fell back to Python3.7 for at least one package:
    RUN apt-get install -y MANY_PYTHON2_PACKAGES_PERHAPS_INSTALLED_WITH_PYTHON3.7_DEFAULT
    # These packages perhaps need another Python version than the previous?
    RUN apt-get install -y python-matplotlib python-sympy
    RUN python -m pip install MANY_PYTHON2_PACKAGES_NOT_IN_APT-GET
    

    更新:运行时我再次update遇到错误。我只是放弃了更新。这很有效,因为它之前已经运行了几行:

    从:

    RUN apt-get -o Acquire::Check-Valid-Until=false update && \
        apt-get install -y ...
    

    至

    RUN apt-get install -y ...
    
    • 0

相关问题

  • 如何编写 shell 脚本来安装应用程序列表?

  • 如何查看存档中可用的软件包的所有版本?

  • 是否可以说出我安装的哪些软件包不在原版安装中?

  • 如何删除 PPA?

  • 使用 apt-get upgrade 时如何强制安装内核更新?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve