Ubuntu 1604 Ctrl+Alt+T can't not start terminal

I just tried to install python 3.6 on my Ubuntu 16.04 system, and now I cant run the terminal from the launcher or from Ctrl+Alt+T. I tried to run gnome-terminal from XTerm and got the following message:

sudo apt-get install xterm
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'
  • solution 1:
    You don’t have to point Python3 to python3.5 , just running the commands:
cd /usr/lib/python3/dist-packages/gi/ 
sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so 
sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so
  • solution 2:

Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:

sudo rm /usr/bin/python3
sudo ln -s python3.5 /usr/bin/python3

reference

Gnome terminal will not start

    原文作者:庞贝船长
    原文地址: https://www.jianshu.com/p/0dbc7612dc35
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞