Как я могу исправить ошибку apt "W: Целевые пакеты ... настраиваются несколько раз"?

Я только что установил 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:87W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (restricted/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (multiverse/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (multiverse/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (multiverse/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11 (multiverse/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11-icons (multiverse/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: 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:87W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (restricted/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (multiverse/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (multiverse/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (multiverse/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target Translations (multiverse/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: Target DEP-11 (multiverse/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:33 and /etc/apt/sources.list:87W: 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 для автоматизации этой задачи. Вы можете найти самая последняя версия здесь.

Установка:

  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. Следуйте инструкциям, появляющимся на экране.

Если вы хотите, чтобы сообщить о проблеме, оставьте комментарий или разветвите исходный код, пожалуйста, сделайте это на 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_functionimport aptsources.sourceslistEMPTY_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 duplicatesif __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 пакет. Строки не обязательно должны быть точными дубликатами (даже после нормализации), но этого достаточно, если type, URI, suite и хотя бы один компонент перекрываются.

Я не уверен, что тест на равенство верен во всех угловых случаях (например, различные строки “option”).

Для меня (16.04 LTS) собирается

>>>>Системные настройки Программное обеспечение и обновления Другое программное обеспечение и удаление каждой повторяющейся записи из списка работало нормально.

Сбросьте настройки ваших репозиториев подобный этому:

  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.

Поскольку ошибки говорят вам, в чем проблема, и что все проблемы связаны с одной дублированной строкой, вы можете легко исправить это вручную с помощью текстового редактора, такого как vim, nano и т.д. Одним из преимуществ этого является то, что вы можете точно видеть, в чем проблема и что вы делаете, чтобы ее устранить.

В вашем случае с помощью sudo или от имени root откройте /etc/apt/sources.список в текстовом редакторе. Удалите либо строку 33, либо строку 87. Сначала вы можете визуально проверить, являются ли они дубликатами.

Если тебе нравится vim...

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

Или, чтобы выйти, если вы совершите ошибку...

:q!             # to quit without saving any changes

Для систем на базе Ubuntu с Linux mint перейдите к >>Обслуживание источников программного обеспечения Удаление дубликатов пакетов

Я не думаю, что это полезный совет для вашей проблемы с установщиком Ubuntu, который вы не можете контролировать. Тем не менее, если у вас просто возникла эта ошибка после самостоятельного написания некоторых команд установки, возможно, это поможет:

В файле Dockerfile для проекта python2 ROS и множества установленных 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 также в соответствии с этот. Затем я снова переключился на

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-sympyRUN 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 ...

Отредактируйте файл /etc/apt/sources вручную.перечислите и удалите дублирующиеся строки.

Я вижу много “решений”, но нет объяснения, почему это происходит.

@PJBrunet этот вопрос не спрашивает, почему, он просит его исправить это. Не стесняйтесь задавать новый вопрос, сосредоточив внимание на том, почему.