Ubuntu – How to solve this error related to gnome-terminal & software updater

command linegnomegnome-terminalupdate-manager

Due to this error, my terminal is neither opening from shortcut key (CTRL+ALT+T] nor from launcher. It only opens from "Open Terminal" option by right clicking on desktop.

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

Image of the above error

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'

I think due to this I'm unable to launch my terminal.

UPDATE: Now only software updater problem is left unsolved. Please help!

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'

Best Answer

  • From Comments:

    • For GDBus error:

      Remove 20packagekit using:

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

      Retry the update and upgrade:

      sudo apt-get update && sudo apt-get upgrade
      
    • For 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