我该如何解决与 gnome-terminal 和软件更新程序相关的这个错误?

我该如何解决与 gnome-terminal 和软件更新程序相关的这个错误?

由于此错误,我的终端既无法通过快捷键(CTRL++ ])打开ALTT也无法通过启动器打开。它只能通过右键单击桌面从“打开终端”选项打开。

prateek@Home-Alone:~$ sudo apt-get upgrade
[sudo] password for prateek: Reading package lists... Done
Building dependency tree Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

prateek@Home-Alone:~$ sudo apt-get update 
Ign:1 http://dl.google.com/linux/chrom... stable InRelease
Hit:2 Index of /node_8.x/ xenial InRelease 
Hit:3 Index of /ubuntu xenial InRelease 
Hit:4 Index of /repos/vscode/ stable InRelease 
Hit:5 Index of /atareao/atareao/ubuntu xenial InRelease 
Hit:6 Index of /damien-moore/codeblocks-stable/ubuntu xenial InRelease
Hit:7 https://cli-assets.heroku.com/br... ./ InRelease 
Get:8 Index of /ubuntu xenial-security InRelease [107 kB] 
Hit:9 http://linux.teamviewer.com/deb stable InRelease 
Ign:10 http://dl.google.com/linux/chrom... stable InRelease 
Get:11 Index of /ubuntu xenial-updates InRelease [109 kB] 
Hit:12 Index of /jonathonf/python-3.6/ubuntu xenial InRelease 
Hit:13 http://linux.teamviewer.com/deb preview InRelease 
Hit:14 http://dl.google.com/linux/chrom... stable Release 
Get:15 Index of /ubuntu xenial-backports InRelease [107 kB] 
Hit:16 Index of /openshot.developers/ppa/ubuntu xenial InRelease
Hit:18 Index of /paolorotolo/android-studio/ubuntu xenial InRelease
Hit:19 http://dl.google.com/linux/chrom... stable Release 
Hit:20 Index of /webupd8team/java/ubuntu xenial InRelease 
Hit:22 Index of /webupd8team/y-ppa-manager/ubuntu xenial InReleaseFetched 323 kB in 2s (129 kB/s)
Error: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 1
Reading package lists... Done

上述错误图片

prateek@Home-Alone:~$ gnome-terminal
Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
    from . import _gi
ImportError: cannot import name '_gi'
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 23, 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'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
    from . import _gi
ImportError: cannot import name '_gi'

我想由于这个原因,我无法启动我的终端。



更新:现在只剩下软件更新程序问题未解决。请帮忙!

prateek@Home-Alone:~$ software-properties-gtk

Traceback (most recent call last):

  File "/usr/bin/software-properties-gtk", line 32, in <module>
    import aptsources

  File "/usr/lib/python3/dist-packages/aptsources/__init__.py", line 3, in <module>

    import apt_pkg

ModuleNotFoundError: No module named 'apt_pkg'

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 23, 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'

Original exception was:

Traceback (most recent call last):

  File "/usr/bin/software-properties-gtk", line 32, in <module>
    import aptsources

  File "/usr/lib/python3/dist-packages/aptsources/__init__.py", line 3, in <module>
    import apt_pkg

ModuleNotFoundError: No module named 'apt_pkg'

答案1

来自评论:

  • 对于GDBus错误:

    删除20packagekit使用:

    sudo rm /etc/apt/apt.conf.d/20packagekit
    

    重试更新并升级:

    sudo apt-get update && sudo apt-get upgrade
    
  • 为了GNOME Terminal not starting

    cd /usr/lib/python3/dist-packages/gi/
    sudo ln -s _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
    sudo ln -s _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so
    

答案2

您可以尝试重新安装您的 aptdeamon:sudo apt-get install --reinstall aptdaemon

或者/和升级您的操作系统:sudo apt-get update; sudo apt-get upgrade; sudo apt-get dist-upgrade

相关内容