我昨天安装了Python3,但是我感觉我没有做好:
:~$ 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 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)
当我尝试使用以下命令删除 PPA(404)时,出现了同样的错误:
add-apt-repository --remove ppa:/jonathonf/python-3.7
然而,Python 运行得很顺畅。这可能也有帮助:
~$ python --version
Python 2.7.15rc1
~$ python3 --version
Python 3.7.0b3
~$ type -a python3; file $(type -aP python3)
python3 is /usr/bin/python3
/usr/bin/python3: symbolic link to /etc/alternatives/python3
~$ python3.5 --version # Expected, I installed 3.6 and 3.7 - I only added the 3.5 link as a following desperate attempt
bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory
~$ python3.6 --version
Python 3.6.5
~$ python3.7 --version
Python 3.7.0b3
运行 Ubuntu 18.04
重新安装后错误仍然存在gnome-terminal
。我发现这个帖子没有答案,但他们建议重新安装 Ubuntu,我希望他们在开玩笑(:
答案1
步骤 3您遵循的说明是错误的。不同版本的 Python 3 不是替代品。幸运的是,应该很容易修复。只需使用与帖子底部更新中的命令类似的命令即可:
sudo rm /usr/bin/python3
sudo ln -s python3.6 /usr/bin/python3