Python 找不到名为 apt_pkg 的模块

Seb*_*ian 3 add-apt-repository python3 16.04

我正在运行 Ubuntu 16.04,在我的服务器上,我有 2 个版本的 python、python3.5 和 python3.6。

我已经尝试过的是:

卸载 python3-apt并重新安装它,没有帮助仍然是同样的错误。

编辑:在python3我有 python3.6 运行。

添加错误:

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
Run Code Online (Sandbox Code Playgroud)

Seb*_*ian 9

就我而言,因为我安装了 2 个版本的 python, python3.5 和 python3.6 ,在 python3.6 版本上找不到该模块,所以我所做的感谢@Emmet 建议是:

nano /usr/bin/add-apt-repository编辑的行#! /usr/bin/python3#! /usr/bin/python3.5现在add-apt-repository命令再次工作。