add-apt-repository 引发 Python 错误

add-apt-repository 引发 Python 错误

我想安装Numix图标主题,因此我需要添加ppa,但它奇怪地引发了这个错误:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 163, in <module>
    if not sp.add_source_from_shortcut(shortcut, options.enable_source):
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 750, in add_source_from_shortcut
    self.set_modified_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 484, in set_modified_sourceslist
    self.save_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 650, in save_sourceslist
    self.sourceslist.save()
  File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 415, in save
    files[source.file] = open(source.file, "w")
FileNotFoundError: [Errno 2] Böyle bir dosya ya da dizin yok: '/etc/apt/sources.list.d/numix-ppa-trusty.list'

从代码中,我了解到Python想要打开一个配置文件,但由于它找不到它,所以它也无法创建它。 (管他呢...)

这个错误的根源是什么?怎么处理呢?还有,Linux 是否使用 Python 来执行存储库命令(因为这更有趣)?

我运行了这些代码:

sudo apt-add-repository ppa:numix/ppa
sudo apt-get update
sudo apt-get install numix-icon-theme numix-icon-theme-circle

操作系统:Xubuntu 14.04 LTS

编辑:编辑sources.list

每当我运行这段代码时,我都会遇到https://launchpad.net/~numix/+archive/ubuntu/ppa关联。所以我在sources.list中尝试了这些:

###############################################
# Number One: Add The Link To The End Of File #
###############################################
deb https://launchpad.net/~numix/+archive/ubuntu/ppa trusty partner
deb-src deb https://launchpad.net/~numix/+archive/ubuntu/ppa trusty partner
# I used "deb", "deb-src" and "trusty partner" patterns to achieve my goal, but it failed.

###################################
# Number Two: Change Link Pattern #
###################################
deb https://launchpad.net/~numix/+archive/ubuntu trusty partner
deb-src deb https://launchpad.net/~numix/+archive/ubuntu trusty partner
# I also tried those since other repository links ends with "ubuntu" instead of "ppa" but this also failed.

答案1

您的系统似乎/etc/apt/sources.list.d缺少该目录(您可以使用 确认这一点ls /etc/apt/sources.list.d,它应该显示“没有这样的文件或目录”)。如果确实如此,请使用以下命令重新创建它

sudo mkdir /etc/apt/sources.list.d

然后再试一次。

相关内容