首页 > 解决方案 > /usr/bin/python3:错误的解释器;如何让python3再次工作?

问题描述

我安装了两个版本的 python(python - 2.7.12 和 python3 - 3.5.2)。安装 python 3.7.7 后,我想通过创建一些命令使其成为 python3 命令的默认值。但不幸的是,python3 命令不再起作用!

fogang@FF:~$ python
Python 2.7.12 (default, Oct  8 2019, 14:14:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
fogang@FF:~$ python3.7
Python 3.7.7 (default, Mar 10 2020, 17:25:08) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
fogang@FF:~$ python3
bash: /usr/lib/command-not-found : /usr/bin/python3 : mauvais interpréteur: Aucun fichier ou dossier de ce type
fogang@FF:~$

翻译:“/usr/bin/python3:错误的解释器:没有这种类型的文件或文件夹”

有我的 /usr/bin

fogang@FF:/usr/bin$ ls python*
python     python2.7-config  python3.5-config   python3.7         python3.7m-config  python3m-config  pythontex3
python2    python2-config    python3.5m         python3.7-config  python3-config     python-config
python2.7  python3.5         python3.5m-config  python3.7m        python3m           pythontex

标签: python

解决方案


/usr/bin/python3不见了。根据评论,您使用的是 Ubuntu,因此解决方案是简单地恢复它:

sudo ln -s python3.5 /usr/bin/python3

请注意,在 Ubuntu 上更改系统python3版本会破坏一些东西,因此更好的解决方案是使用别名,例如放入alias python3="python3.7"您的 bashrc。


推荐阅读