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
相关推荐
戊本菌8 小时前
进程(三)runqueue 与 Linux 的 O(1) 调度
linux·运维·服务器
光电笑映9 小时前
TCP 为什么可靠?从三次握手、滑动窗口到拥塞控制全面拆解(下)
linux·网络·网络协议·tcp
yz_aiks10 小时前
Termux 使用教程:把安卓手机变成随身 Linux(装 Python、SSH 远程、跑自动化脚本)
android·linux·python·智能手机·ssh·termux
hi_ro_a14 小时前
Ext系列⽂件系统详解
linux·服务器·操作系统
你住过的屋檐16 小时前
【SeaweedFS】Linux上搭建SeaweedFS文件存储服务完整教程
linux·运维·服务器
少司府17 小时前
嵌入式外设篇(三)GPIO·三:MCU系统结构、总线与统一编制
linux·python·stm32·单片机·嵌入式硬件·mcu·嵌入式软件
不积跬步无以至千里mmbb2618 小时前
Rust三大核心:Trait Crate Mod详解
linux·rust
无忧.芙桃1 天前
Linux系统编程(四):用户与权限管理
linux·运维·服务器
戊本菌1 天前
进程(三)进程优先级:谁先上 CPU
linux·c语言·硬件架构
aningx2 天前
Arch 系用 greetd 实现开机自动进 Plasma Wayland,注销自动回桌面
linux