Ubuntu16.04使用sudo add-apt-repository时报错:aptsources.distro.NoDistroTemplateException

本文介绍了解决在Ubuntu系统中使用sudo add-apt-repository命令时遇到的NoDistroTemplateException错误的方法。该问题由安装了优麒麟系统的软件引起,导致lsb-release文件被修改。通过调整该文件内容为正确的Ubuntu发行版信息可以解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用sudo add-apt-repository 时候,系统报错:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 96, in <module>
    sp = SoftwareProperties(options=options)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 114, in __init__
    self.reload_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 607, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)    
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 89, in get_sources
    (self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Kylin/kylin

原因:
我装了ukylin优麒麟系统的软件(ukylin-wine和ukylin-wechat),导致Ubuntu的系统配置lsb-release文件被修改了。而且系统设置中的software&updates都打不开了!
可以看到/etc/lsb-release文件的内容变成了这样:

DISTRIB_ID=Kylin
DISTRIB_RELEASE=V10
DISTRIB_CODENAME=kylin
DISTRIB_DESCRIPTION="Kylin V10 SP1"
DISTRIB_KYLIN_RELEASE=V10
DISTRIB_VERSION_TYPE=enterprise
DISTRIB_VERSION_MODE=normal

解决方法:
修改/etc/lsb-release里面的内容:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

注: 具体的发型号是16.04的那个版本我忘了,随便写个16.04.5吧。

参考:

  1. Ubuntu安装软件时报错:aptsources.distro.NoDistroTemplateException: Error:Could not find a distribution templ
  2. Ubuntu18.04.5 LTS 安装优麒麟应用商店的坑
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值