Ubuntu启动不了Terminal
本机原本使用Python3.10,切换Python3.8之后,终端启动不了。
问题确认是否是切换Python版本导致
在vscode终端或者tty模式输入sudo gnome-terminal
,会有报错信息:
bash
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 11, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 67, in <module>
from gi.repository import Gio
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)
或者直接journalctl -xe | grep -i python
,查看是否是ImportError: cannot import name '_gi' from 'gi'
导致的,如果是就需要进行下面操作。
解决方法
- 恢复系统版本Python
- 修改gnome terminal 的 shebang 行:修改
/usr/bin/gnome-terminal
文件的第一行:
python
#!/usr/bin/python3.10