Ubuntu22.04提示找不到python命令的解决方案
问题背景
在Ubuntu22.04中按照获取Openharmony源码中的如下命令:
// 方式一(推荐):通过repo + ssh下载(需注册公钥,请参考码云帮助中心)。
repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
执行repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
命令时,报如下错误:
/usr/bin/env: 'python': No such file or directory
说明系统找不到 python
命令。Ubuntu 22.04 及以后默认只安装 python3,没有 python 软链接
。
解决方法
1. 创建 python 到 python3 的软链接(推荐
)
shell
sudo ln -s /usr/bin/python3 /usr/bin/python
然后再执行你的 repo init 命令即可。
2. 或者直接安装 python-is-python3(更推荐
)
sudo apt update
sudo apt install python-is-python3
这样 /usr/bin/python
会自动指向 python3
总结:
只需让系统有 python 命令即可,推荐安装 python-is-python3
。