18.04--GnomeTerminal 无法启动

18.04--GnomeTerminal 无法启动

当我从 Xterm 运行 gnome-terminal 时,我得到:

文件“/usr/lib/python3/dist-packages/gi/在里面.py”,第 42 行,来自 . import _gi ImportError: 无法从‘gi’导入名称‘_gi’(/usr/lib/python3/dist-packages/gi/在里面.py)

我已经尝试过了:

sudo rm /usr/bin/python3
sudo ln -s python3.5 /usr/bin/python3
sudo apt-get install python3-gi
sudo apt install python3.5

我也重新安装了终端,但什么也没起作用。

Python output: 
>> import gi
>> gi.__file__
>> '/usr/lib/python3/dist-packages/gi/__init__.py'

Gnome 终端无法启动 你的 python3 安装已损坏 终端和软件更新在打开时崩溃,与 Python 安装有关

-rwxr-xr-x  1 root root        3452 Jul 19  2017 activate-global-python-argcomplete3
lrwxrwxrwx  1 root root          26 Mar 26  2018 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x  1 root root        1056 Apr 16  2018 dh_python2
lrwxrwxrwx  1 root root          29 Mar 26  2018 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx  1 root root          23 Nov 12 09:31 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx  1 root root          23 Aug  3 20:54 pdb3.5 -> ../lib/python3.5/pdb.py
lrwxrwxrwx  1 root root          23 Oct 22 07:32 pdb3.6 -> ../lib/python3.6/pdb.py
-rwxr-xr-x  1 root root       88224 Dec 17  2017 pvtkpython
lrwxrwxrwx  1 root root          31 Oct 25 07:11 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx  1 root root          26 Mar 26  2018 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx  1 root root          18 Dec 30 16:08 python -> /usr/bin/python3.6
lrwxrwxrwx  1 root root           9 Apr 16  2018 python2 -> python2.7
-rwxr-xr-x  1 root root     3670448 Nov 12 09:31 python2.7
lrwxrwxrwx  1 root root          33 Nov 12 09:31 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root          16 Apr 16  2018 python2-config -> python2.7-config
-rwxr-xr-x  1 root root         365 Aug 22  2016 python2-qr
lrwxrwxrwx  1 root root          18 Dec 30 16:12 python3 -> /usr/bin/python3.5
-rwxr-xr-x  2 root root     4117024 Aug  3 20:54 python3.5
lrwxrwxrwx  1 root root          33 Aug  3 20:54 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x  2 root root     4117024 Aug  3 20:54 python3.5m
lrwxrwxrwx  1 root root          34 Aug  3 20:54 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x  2 root root     4522328 Oct 22 07:32 python3.6
lrwxrwxrwx  1 root root          33 Oct 22 07:32 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x  1 root root         401 Feb 21  2018 python3.6-coverage
-rwxr-xr-x  2 root root     4522328 Oct 22 07:32 python3.6m
lrwxrwxrwx  1 root root          34 Oct 22 07:32 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root          16 Oct 25 07:11 python3-config -> python3.6-config
-rwxr-xr-x  1 root root         397 Feb 21  2018 python3-coverage
lrwxrwxrwx  1 root root          10 Oct 25 07:11 python3m -> python3.6m
lrwxrwxrwx  1 root root          17 Oct 25 07:11 python3m-config -> python3.6m-config
-rwxr-xr-x  1 root root        2555 Jul 19  2017 python-argcomplete-check-easy-install-script3
-rwxr-xr-x  1 root root         314 Jul 19  2017 python-argcomplete-tcsh3
lrwxrwxrwx  1 root root          16 Apr 16  2018 python-config -> python2.7-config
lrwxrwxrwx  1 root root          29 Apr 16  2018 pyversions -> ../share/python/pyversions.py
-rwxr-xr-x  1 root root        2665 Jul 19  2017 register-python-argcomplete3
-rwxr-xr-x  1 root root       14424 Dec 17  2017 vtk6python
-rwxr-xr-x  1 root root        2975 Nov 12 09:31 x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root          34 Aug  3 20:54 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x  1 root root        3246 Aug  3 20:54 x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx  1 root root          34 Oct 22 07:32 x86_64-linux-gnu-python3.6-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x  1 root root        3283 Oct 22 07:32 x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root          33 Oct 25 07:11 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.6-config
lrwxrwxrwx  1 root root          34 Oct 25 07:11 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root          33 Apr 16  2018 x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2.7-config

答案1

在发出上述类似命令之前,请始终记下之前的版本...因此,在发出此命令之前

sudo rm /usr/bin/python3

您应该通过发出以下命令来记录默认版本

python3 --version

在 ubuntu 18.10 上显示

Python 3.6.7

现在你需要调查一下 18.04 标准版正在使用什么,然后把它放回去……在不知道的情况下,你可以通过发出以下命令来查看你的机器上有哪些 python 版本

which python
which python3

可以说类似

python3 is hashed (/usr/bin/python3)

因此进入该目录并按如下方式查看其兄弟目录

cd /usr/bin/

ls -la | grep python

对于我来说,18.10 显示

lrwxrwxrwx  1 root root           26 Jul 23 08:39 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x  1 root root         1056 Jun  7  2018 dh_python2
lrwxrwxrwx  1 root root           29 Jul 23 08:39 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx  1 root root            7 Sep 23 14:14 fail2ban-python -> python3
lrwxrwxrwx  1 root root           23 Oct  2 18:12 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx  1 root root           23 Oct 22 07:32 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx  1 root root           31 Oct 25 07:11 py3versions -> ../share/python3/py3versions.py
-rwxr-xr-x  1 root root          378 Aug 28 16:17 pybabel-python2
lrwxrwxrwx  1 root root           26 Jul 23 08:39 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx  1 root root            7 Jun  7  2018 python -> python2
lrwxrwxrwx  1 root root            9 Jun  7  2018 python2 -> python2.7
-rwxr-xr-x  1 root root      3690840 Oct  2 18:12 python2.7
lrwxrwxrwx  1 root root           33 Oct  2 18:12 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root           16 Jun  7  2018 python2-config -> python2.7-config
-rwxr-xr-x  1 root root          154 Sep 20 05:50 python2-pbr
lrwxrwxrwx  1 root root            9 Oct 25 07:11 python3 -> python3.6
-rwxr-xr-x  2 root root      4534680 Oct 22 07:32 python3.6
lrwxrwxrwx  1 root root           33 Oct 22 07:32 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x  2 root root      4534680 Oct 22 07:32 python3.6m
lrwxrwxrwx  1 root root           34 Oct 22 07:32 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root           16 Oct 25 07:11 python3-config -> python3.6-config
lrwxrwxrwx  1 root root           10 Oct 25 07:11 python3m -> python3.6m
lrwxrwxrwx  1 root root           17 Oct 25 07:11 python3m-config -> python3.6m-config
lrwxrwxrwx  1 root root           14 Jun  7  2018 python-config -> python2-config
lrwxrwxrwx  1 root root           29 Jun  7  2018 pyversions -> ../share/python/pyversions.py
-rwxr-xr-x  1 root root         2971 Oct  2 18:12 x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root           33 Jun  7  2018 x86_64-linux-gnu-python2-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root           34 Oct 22 07:32 x86_64-linux-gnu-python3.6-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x  1 root root         3283 Oct 22 07:32 x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root           33 Oct 25 07:11 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.6-config
lrwxrwxrwx  1 root root           34 Oct 25 07:11 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root           31 Jun  7  2018 x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2-config

您可能会看到其他 Python 版本......

看起来 18.04 想要 python3 是 3.6.7...所以问题

sudo update-alternatives --config python

它会给你选择 3.6.7 的选项

相关内容