如何解决 ModuleNotFoundError:没有名为“apt_pkg”的模块

如何解决 ModuleNotFoundError:没有名为“apt_pkg”的模块

我尝试使用以下命令添加 ppa

sudo add-apt-repository ppa:nathan-renniewaldock/flux

我收到以下错误。

panda123@panda123:~$ sudo add-apt-repository ppa:nathan-renniewaldock/flux
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'

当我时ran ls -l /usr/lib/python3/dist-packages/apt_pkg*,我得到了以下输出。

panda123@panda123:~$ ls -l /usr/lib/python3/dist-packages/apt_pkg*
lrwxrwxrwx 1 root root     39 Jul 27 18:47 /usr/lib/python3/dist-packages/apt_pkg.cpython-34m-x86_64-linux-gnu.so -> apt_pkg.cpython-35m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 310268 May 21 19:50 /usr/lib/python3/dist-packages/apt_pkg.cpython-35m-i386-linux-gnu.so
lrwxrwxrwx 1 root root     39 Jul 27 18:49 /usr/lib/python3/dist-packages/apt_pkg.so -> apt_pkg.cpython-36m-x86_64-linux-gnu.so

运行python -V后输出如下

panda123@panda123:~$ python -V
Python 2.7.12

相关内容