Skip to content

Instantly share code, notes, and snippets.

@davidfoerster
Last active September 25, 2022 19:55
Show Gist options
  • Select an option

  • Save davidfoerster/780daa8086b924b1837a06cc486af672 to your computer and use it in GitHub Desktop.

Select an option

Save davidfoerster/780daa8086b924b1837a06cc486af672 to your computer and use it in GitHub Desktop.
Migrated to https://github.com/davidfoerster/apt-remove-duplicate-source-entries
@rat

rat commented May 14, 2016

Copy link
Copy Markdown

work like a charm

@matthieu-gendreau

Copy link
Copy Markdown

Worked for me too.

@CarnedeTun

Copy link
Copy Markdown

David F thanks for automating the detection/deactivation of duplicates. I am a total newbie - tried python3 apt-remove-duplicate-source-entries.py in dash stored on my Desktop
but got python3: can't open file 'apt-remove-duplicate-source-entries.py': [Errno 2] No such file or directory I know I am doing smth wrong but exactly what? Ty

@baudday

baudday commented May 18, 2016

Copy link
Copy Markdown

@CarnedeTun Your problem is in the error message.

No such file or directory

You're either in the wrong directory when you attempt to execute the script or you named it something different from what you're trying to execute

@CarnedeTun

Copy link
Copy Markdown

@baudday thanks

I tried to run
/home/omegatron/Desktop/apt-remove-duplicate-source-entries.py

And it gave me this:
`omegatron@omegatron-Satellite-C655D:~$ /home/omegatron/Desktop/apt-remove-duplicate-source-entries.py
Overlapping source entries:

  1. /etc/apt/sources.list: deb-src http://ubuntu.mirrors.linux.ro/archive/ xenial main restricted #Added by software-properties
  2. /etc/apt/sources.list: deb-src http://ubuntu.mirrors.linux.ro/archive/ xenial main multiverse universe #Added by software-properties
    I disabled the latter entry.

1 source entries were disabled:

deb-src http://ubuntu.mirrors.linux.ro/archive/ xenial main multiverse universe #Added by software-properties

Do you want to save these changes? (y/N)
omegatron@omegatron-Satellite-C655D:~$
`

But when I tried sudo apt-get update it still gave me this:
W: Target Sources (main/source/Sources) is configured multiple times in /etc/apt/sources.list:2 and /etc/apt/sources.list:7 W: Target Sources (main/source/Sources) is configured multiple times in /etc/apt/sources.list:2 and /etc/apt/sources.list:7
Thanks again for any additional help.

@yashhsethiya

yashhsethiya commented May 31, 2016

Copy link
Copy Markdown

on running
sudo python3 apt-remove-duplicate-source-entries.py
showing error

Traceback (most recent call last):
  File "apt-remove-duplicate-source-entries.py", line 8, in <module>
    import aptsources.sourceslist
ImportError: No module named 'aptsources'

please suggest what to do

@ctorresr

ctorresr commented Jun 3, 2016

Copy link
Copy Markdown

@yashhsethiya You are probably missing python-apt package.

sudo apt-get install python-apt

@gwarah

gwarah commented Jul 1, 2016

Copy link
Copy Markdown

thanks, works fine, but runs as:

sudo python3 apt-remove-duplicate-source-entries.py

@ravingupta

Copy link
Copy Markdown

works for me... awesome

@Ammly

Ammly commented Jul 19, 2016

Copy link
Copy Markdown

Thanks, works on Ubuntu 16.04

@wwmbes

wwmbes commented Jul 25, 2016

Copy link
Copy Markdown

on Ubuntu 16.04 I get this result:
$ sudo python3 apt-remove-duplicate-source-entries.py
No duplicated entries were found.

[ But the following still happens... ]

$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://za.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://ppa.launchpad.net/deluge-team/ppa/ubuntu xenial InRelease
Hit:4 http://za.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:5 http://za.archive.ubuntu.com/ubuntu xenial-backports InRelease
Reading package lists... Done
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Translations (main/i18n/Translation-en_ZA) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Packages (universe/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Translations (universe/i18n/Translation-en_ZA) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Translations (universe/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target DEP-11 (universe/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target DEP-11-icons (universe/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Translations (main/i18n/Translation-en_ZA) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:55
W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Packages (universe/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Translations (universe/i18n/Translation-en_ZA) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target Translations (universe/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target DEP-11 (universe/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55
W: Target DEP-11-icons (universe/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:18 and /etc/apt/sources.list:55

@davidfoerster

davidfoerster commented Aug 1, 2016

Copy link
Copy Markdown
Author

@SnaasebKram: Could you please file an issue report and provide a link to your /etc/apt/sources.list? The comparison for duplicate entries is not perfect because I'm not exactly sure what entries Apt considers equal but a sample like yours would help tweaking that.

@davidfoerster

Copy link
Copy Markdown
Author

@yashhsethiya: You need to install the python3-apt package. The most recent release makes that clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment