报错ModuleNotFoundError: No module named ‘apt_pkg‘,解决办法

最近下载opencv时,使用指令添加源的时候,报错

root@83ae74c1bc33:~ add-apt-repository ppa:timsc/opencv-3.3
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

对的,就是这个错误ModuleNotFoundError: No module named ‘apt_pkg’

解决办法:

sudo apt-get install python3-apt --reinstall
cd /usr/lib/python3/dist-packages
 cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so   # 注意此处apt_pkg.cpython-3x,最好利用tab自动补全一下
 # 接下来就可以继续操作了
sudo  add-apt-repository ppa:timsc/opencv-3.3

你可能感兴趣的:(ubuntu系统)