ubuntu 安装python3.6后,terminal终端打不开问题
由于Ubuntu16.04,自带Python2.7和Python3.5
当我安装完Python3.6.5后,terminal终端打不开了,
jekay@jekay-pc:~$ 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'
处理方法:
1: Ctrl+Alt+F1 打开系统终端
2:进入默认Python3 gi 目录
jekay@jekay-pc:~$ cd /usr/lib/python3/dist-packages/gi/
3:复制两份文件,重命名,将版本3.5换成3.6
jekay@jekay-pc:/usr/lib/python3/dist-packages/gi$ sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
jekay@jekay-pc:/usr/lib/python3/dist-packages/gi$ sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so
4:Ctrl+Alt+F7回到桌面
OK,回复正常
来自以下博客来源:
https://blog.csdn.net/qq_33591205/article/details/79659045
https://blog.csdn.net/jaket5219999/article/details/78465251