Ubuntu17.04 执行add-apt-repository时报错No module named 'softwareproperties'

在搞Ubuntu主题时用到了add-apt-repository,执行一直报错,报错内容如下:
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 10, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
ModuleNotFoundError: No module named 'softwareproperties'


定位add-apt-repository,在目录/usr/bin目录下,打开发现这是用Python编写的,因为之前安装anaconda,把/usr/bin/python改掉了,换成了python3.6了,然后进入python3.6的解释器执行语句: from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler果断报错,如下:
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'softwareproperties'


然后进入python2.7的解释器在执行上述语句,报错如下:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name shortcut_handler


原来是因为Python版本不同,Python的模块有些许的不同,正好我的系统里还装有Python3.5(这个是系统自带的),执行上述语句,结果如下:
>>> from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 25, in <module>
    import lsb_release
ModuleNotFoundError: No module named 'lsb_release'
Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 25, in <module>
    import lsb_release
ModuleNotFoundError: No module named 'lsb_release'


现在不报模块的错误了,那就直接将add-apt-repository中的第一行改为#!/usr/bin/python3.5 即可。
问题解决。
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值