python -/usr/bin/python : bad interpreter: No such file or directory after installing python 2. 7

标签 python python-3.x python-2.7 ubuntu ubuntu-20.04

我在 Ubuntu 20.04 上安装了 python3,并且有一个需要安装 python 2.7 的应用程序。 安装python 2.7后,似乎找不到python

 /usr/bin/python: bad interpreter: No such file or directory

which pythonwhich python2which python3 不返回任何结果

以下是/usr/bin 的内容:

root@ip-10-10-10-201:/home/ubuntu# ls -alh /usr/bin/pyt*
lrwxrwxrwx 1 root root    9 Mar 13  2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3.5M Aug  4 11:16 /usr/bin/python2.7
lrwxrwxrwx 1 root root    9 Mar 13  2020 /usr/bin/python3 -> python3.8
lrwxrwxrwx 1 root root   16 Mar 13  2020 /usr/bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root 5.3M Jul 28 12:59 /usr/bin/python3.8
lrwxrwxrwx 1 root root   33 Jul 28 12:59 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config

如果我需要两个 python(2.7 和 3.8)都工作,我不知道如何让它工作。 我应该将需要 phyton2 的脚本中的 #!/usr/bin/python 更改为 #!/usr/bin/python2 吗?

非常感谢您的帮助。 节日快乐!

最佳答案

按照@ForceBru的建议,将脚本从 /usr/bin/python 更改为 /usr/bin/python2 似乎可行。

这是因为 Ubuntu Python 软件包始终以 python2 和 python3 形式出现,而不是 python。

关于python -/usr/bin/python : bad interpreter: No such file or directory after installing python 2. 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65413965/

相关文章:

python - 可以接受使用自定义异常作为哨兵值吗?

python - 使用 shutil.make_archive() 创建存档同时排除某些路径

python - web.py 可以处理多少个请求?

python - 如果答案无效则重新启动 if 循环

python-3.x - 如何在 Python 中使用时区记录当前时间?

Python3 突然消失了(在 macOS 上)——至少用了一年

Python CGI - UTF-8 不工作

python - 根据两个键排序,第一个降序排序,第二个升序排序

python - Autodoc Sphinx 出现 django 错误

python - 了解 Django 的数据库 API 和模型 - Poll.objects