apt“找不到分发模板”错误

Rya*_*son 16 apt

当我尝试使用 apt-get 安装任何东西时,出现以下错误:

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
Run Code Online (Sandbox Code Playgroud)

知道这意味着什么以及如何解决吗?

Jos*_*son 24

易于修复 只需这样做

gksudo gedit /etc/lsb-release
Run Code Online (Sandbox Code Playgroud)

然后编辑打开的文件,使其看起来像这样

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu Karmic Koala"
Run Code Online (Sandbox Code Playgroud)

请记住输入您使用的 ubuntu 版本。我正在使用业力考拉,所以我把它放进去。

您可以在底部获得一个列表
http://en.wikipedia.org/wiki/Ubuntu_%28operating_system%29

然后在保存 lsb-release 文件后返回终端,您应该能够添加-apt-repository

  • 你绝对不应该这样做。该文件是 base-files 包的一部分,不应编辑。相反,您应该相应地降级或升级包(并固定触发基本文件更改的其他包)。 (5认同)

Dav*_*ter 7

的内容/etc/lsb-release无效。您需要重新安装该base-files软件包以恢复其预期内容。不幸的是,您不能仅apt-get用于工作。反而,

  1. 转到https://launchpad.net/ubuntu/+source/base-files并查找适用于您的 Ubuntu 版本的部分,

  2. 下载适用于您的版本和架构的最新版本的软件包,

  3. 跑:

    sudo dpkg -i /your/path/to/base-files_*.deb
    
    Run Code Online (Sandbox Code Playgroud)
  4. 进行测试运行

    sudo apt-get install --reinstall base-files
    
    Run Code Online (Sandbox Code Playgroud)