Updated to Python 3.8 - Terminal won't open - [Fixed] but details not understood

eps*_*ror 7 python terminal gnome-terminal

I updated my system (Ubuntu 18.04) from Python 3.6 to Python 3.8, and reset the defaults so that python3 now points to Python 3.8 (and not 3.6). However, since then, the terminal has refused to open using Ctrl + Alt + T, and other obvious methods such as clicking on the icon itself.

When I run gnome-terminal - I get the following:

usernew@HP:/usr/lib/python3/dist-packages/gi$ 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' from partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)
Run Code Online (Sandbox Code Playgroud)

I don't know what this means but I guess it definitely points to the fact that something went wrong during the update. I understand that there are other existing threads on similar issues, but most of them were about updating from Python2 to Python3, so I'm not sure if they're relevant.

Could someone help, please?

重要更新:因此,在阅读此答案后- 我将gnome-terminal脚本的第一行改为#!/usr/bin/python3.6而不是#!/usr/bin/python3.8- 这解决了问题。

此外,当我python3在终端中输入时,我会根据需要使用 Python 3.8.2。

问题仍然存在 -为什么这样做 实际问题是什么?解释会有所帮助,所以我真的知道我在做什么。

谢谢!

wja*_*rea 8

您不应该更改符号链接,/usr/bin/python3因为一堆 Ubuntu 组件依赖于它,并且 Ubuntu 特定的 Python 库(如 Ubuntu 特定的 Python 库)gi仅针对 Ubuntu 随附的 Python 构建构建,后者是 18.04 上的 3.6 版。

请参阅Gnome 终端不会在 Ask Ubuntu 上启动(但请注意,它是关于使用 Python 3.5 的 Ubuntu 16.04)。所以修复它的最好方法是恢复符号链接:

sudo ln -sf python3.6 /usr/bin/python3
Run Code Online (Sandbox Code Playgroud)

至于将 Python 3.8 设置为默认值,您可以在 bashrc 中放置一个别名

alias python3=python3.8
Run Code Online (Sandbox Code Playgroud)

但这只会影响您用户的外壳。例如,在脚本中,如果您想使用 Python 3.8,则必须编写它,即#!/usr/bin/env python3.8