![为什么我必须编辑 /etc/lsb-release 才能使 apt-get 工作?](https://linux22.com/image/833862/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E5%BF%85%E9%A1%BB%E7%BC%96%E8%BE%91%20%2Fetc%2Flsb-release%20%E6%89%8D%E8%83%BD%E4%BD%BF%20apt-get%20%E5%B7%A5%E4%BD%9C%EF%BC%9F.png)
我无法从软件中心打开软件源窗口。我无法使用 apt-get add-apt-repository(和其他东西)。
我在使用 add-apt-repository 时遇到的错误是:
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 160, in <module>
sp = SoftwareProperties(options=options)
File "/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py", line 96, in __init__
self.reload_sourceslist()
File "/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py", line 584, in reload_sourceslist
self.distro.get_sources(self.sourceslist)
File "/usr/lib/python2.7/dist-packages/aptsources/distro.py", line 87, in get_sources
raise NoDistroTemplateException("Error: could not find a "
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template
我的旧 /etc/lsb-release 如下所示:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.10
DISTRIB_CODENAME=quantal
DISTRIB_DESCRIPTION="Ubuntu quantal (Development branch)"
我将其改为:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu precise"
突然间,一切又“正常”了。我不相信它,因为我实际上是在撒谎说我有一个早期版本。为什么我必须做出这种改变?我该怎么做才能让一切以更合理的方式运转?
答案1
这将改变 apt-get 从哪个存储库获取软件。以前,它会尝试从 quantals 存储库的开发分支获取软件。我会尝试编辑该文件,使其看起来像这样:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.10
DISTRIB_CODENAME=quantal
DISTRIB_DESCRIPTION="Ubuntu quantal"
编辑文件运行后sudo apt-get update; sudo apt-get upgrade
,查看 apt-get 是否安装成功。