Ubuntu启动不了Terminal

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'导致的,如果是就需要进行下面操作。

解决方法

  1. 恢复系统版本Python
  2. 修改gnome terminal 的 shebang 行:修改/usr/bin/gnome-terminal文件的第一行:
python 复制代码
#!/usr/bin/python3.10
相关推荐
用户23678298016810 分钟前
Linux systemctl 服务管理命令:从 systemd 架构到实战技巧
linux
LIZHUOLONG135 分钟前
linux 设备初始化
linux·运维·服务器
雪霁清寒1 小时前
麒麟V10用MobaXterm远程连接SSH偶尔卡顿的问题
linux·ssh
ylscode1 小时前
Linux CIFSwitch 内核新漏洞允许攻击者获得 root 权限
linux·运维·服务器
诸葛务农2 小时前
共沸脱水技术及其在光刻胶用PGMEA纯化中的应用(中)
linux·数据库·人工智能
lld9510272 小时前
(二)从验证到执行:策略实时运行全链路
linux·服务器·数据库
坤昱2 小时前
cfs调度类深入解刨——最新内核细节分析5
linux·分布式·cfs调度·eevdf调度·linux调度·linux技术·kernel最新版本内容
阿洛学长2 小时前
Kali Linux 虚拟机安装(VMware Workstation 17)
java·linux·服务器
H Journey2 小时前
source命令、.bashrc 、.bash_profile、/etc/profile配置文件详解
linux·.bashrc
上天_去_做颗惺星 EVE_BLUE3 小时前
Ubuntu Android 虚拟机安装使用教程
android·linux·测试工具·ubuntu·安卓