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
相关推荐
IT大白鼠3 小时前
Linux进程与计划任务管理:技术详解与实战指南
linux·运维·服务器
拾贰_C4 小时前
【Ubuntu | 公共工作站 | mysql 】 MySQL残留物残留数据
linux·mysql·ubuntu
Ujimatsu4 小时前
虚拟机安装Ubuntu 26.04.x服务器版(命令行版)(2026.5)
linux·windows·ubuntu
hweiyu005 小时前
Linux命令:arptables
linux·运维
仙柒4156 小时前
管理网络安全
linux·运维·服务器
福尔摩斯·柯南6 小时前
Ubuntu 14.04/16.04/18.04/20.04/22.04/24.04/26.04全系列LTS长期支持版镜像IOS分享
linux·运维·ubuntu
xiaoming00187 小时前
JAVA项目打包部署运维全流程(多服务、批量)
java·linux·运维
浪客灿心7 小时前
Linux五种IO模型与非阻塞IO
linux·网络
洋哥网络科技7 小时前
centos7 升级openssh-10.2
linux·运维·服务器·系统安全
我先去打把游戏先7 小时前
【保姆级图文教程】:VMware虚拟机安装Ubuntu Server 22.04
linux·数据库·ubuntu