18

When I attempt to install anything using apt-get I get the following error:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 60, in <module>
    sp = SoftwareProperties()   
  File "/usr/lib/python2.6/dist-packages/softwareproperties/SoftwareProperties.py", line 90, in __init__
    self.reload_sourceslist()
  File "/usr/lib/python2.6/dist-packages/softwareproperties/SoftwareProperties.py", line 538, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)    
  File "/usr/lib/python2.6/dist-packages/aptsources/distro.py", line 90, in get_sources
    raise NoDistroTemplateException("Error: could not find a "
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template

Any idea what this means and how to resolve it?

2
  • Can you show the exact command giving this answer?
    – enzotib
    Jun 16, 2011 at 12:04
  • Try to use aptitude.
    – amra
    Jun 16, 2011 at 12:29

3 Answers 3

24

Easy to fix Just do this

gksudo gedit /etc/lsb-release

Then edit the file that opens so that it looks like this

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu Karmic Koala"

Remember to enter which version of ubuntu you are using. I am using karmic koala so I put that in.

You can get a list here towards the bottom
http://en.wikipedia.org/wiki/Ubuntu_%28operating_system%29

Then go back to the terminal after you have saved the lsb-release file and you should be able to add-apt-repository

4
  • Just an observation: Be careful with the uppercase and lowercase letters!
    – user56242
    Apr 23, 2012 at 17:38
  • 6
    You definitely should not do this. That file is part of the base-files package and should not be edited. Instead, you should downgrade or upgrade the package accordingly (and pin the other package that triggered the change of base-files). Jul 29, 2012 at 20:16
  • That sounds great @fish , care to write out an easy step by step explanation of how to do that and post it here as an answer? Aug 5, 2012 at 12:23
  • Here is a great answer that pretty much covers all the steps: askubuntu.com/a/135472/3449 Aug 5, 2012 at 12:46
7

The content of /etc/lsb-release is invalid. You'll need to re-install the base-files package to restore its intended content. Unfortunately you can't just use apt-get for the job. Instead,

  1. go to https://launchpad.net/ubuntu/+source/base-files and look for the section for your Ubuntu release,

  2. download the most recent version of the package available for your release and architecture,

  3. run:

    sudo dpkg -i /your/path/to/base-files_*.deb
    
  4. Make a test run with

    sudo apt-get install --reinstall base-files
    
2
  • There are no .deb files available. I can only download tar files which do not contain any deb inside. Any idea on how to use these?
    – Sakis
    Oct 31, 2023 at 14:28
  • @Sakis I don’t know what you mean. When I expand the package for the Jammy series I get a bunch of .deb files: i.imgur.com/PfteJo7.png Nov 1, 2023 at 18:40
0

I solved it by hacking one python file, to pretend my distro is equal one previous:

for template in self.sourceslist.matcher.templates:
    if( template.name == 'bionic'):  # << added line
        template.name = 'focal';     # << added line
    if (self.is_codename(template.name) and...

/usr/lib/python3/dist-packages/aptsources/distro.py

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .