当我尝试使用以下方式从 Gauke Terminal 或 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'
我无法从启动器和仪表板或使用 Ctrl+Alt+T 打开终端。我尝试重新配置语言环境和 ~/.profile,但没有帮助。
答案1
输出中有两个重要错误,分别位于底部两个 python 错误堆栈:
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi'
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
让我们找出哪些软件包不起作用:
$ dpkg -S /usr/lib/python3/dist-packages/apt/__init__.py
python3-apt: /usr/lib/python3/dist-packages/apt/__init__.py
$ dpkg -S /usr/lib/python3/dist-packages/gi/__init__.py
python3-gi: /usr/lib/python3/dist-packages/gi/__init__.py
所以两个软件包供您重新安装是python3-apt
和python3-gi
然而,这两个方案基本的Ubuntu 系统的操作,而且两者同时失败的可能性确实不大。还发生了一些您尚未提及的重要事情。