ubuntu16.04默认的python版本是2.7,安装3.6.3后,出现gnome-terminal无法启动:
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'
_gi_cairo.cpython-35m-x86_64-linux-gnu.so
修复办法:
1. ctrl+alt+f1 ,输入gnome-terminal,查看无法启动的错误原因
$ gnome-terminal
2. 提示错误信息如下:
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'
3. 查找_gi的库文件
$ ls -la /usr/lib/python3/dist-packages/gi/_gi_cairo.cpython-35m-x86_64-linux-gnu.so
_gi.cpython-35m-x86_64-linux-gnu.so
........
4. 复制一份3.6使用的库文件
$ 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
5. alt+ctrl+f7返回,重新尝试打开终端,问题解决