使用 WSL2 过程中遇到 “/usr/bin/env: ‘python’: No such file or directory”这样的报错,但实际上 Ubuntu 20.04 是安装了 Python3 的。

windows subsystem for linux - /usr/bin/env: ‘python’: No such file or directory - Ask Ubuntu 找到了解决方法。

方法1

1
sudo apt-get install python-is-python3

方法2(我用的就是这种)

1
2
3
4
5
6
# 确保安装了 Python3,如果已经安装可以不用运行这条命令
# apt-get install python3
# 查看 Python3 的位置,可能会输出多个位置,其中一个即可
# whereis python3
# 实际上我只运行了下面这一条命令
sudo ln -s /usr/bin/python3 /usr/bin/python