更换python版本后出现 No module named "apt_pkg"

本文链接:https://blog.csdn.net/jaket5219999/article/details/78464310

$ sudo apt-get remove --purge python-apt
$ sudo apt-get install python-apt -f
$ sudo find / -name "apt_pkg.cpython-35m-x86_64-linux-gnu.so"
$ cd /usr/lib/python3/dist-packages/
$ sudo cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.cpython-36m-x86_64-linux-gnu.so

背景:
系统: ubuntu17

python版本: 默认版本原来是python2.7,  先装了python3.5=python3.5.3 , 后又装了python3.6=python3.6.1

将默认版本改为python3.6后就出现No module named "apt_pkg"的问题了:

本来Ctrl+Alt+T是打开终端的快捷键, 突然用不了, 去到键盘里面的快捷键设置看到命令还是`gnome-terminal`

打开一个终端, 运行`gnome-terminal`就出现如下错误了:

...

Error in sys.excepthook:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

...

posted @ 2019-11-10 21:49  瘋耔  阅读(2195)  评论(0编辑  收藏  举报
跳至侧栏