[OHOS ERROR] FileNotFoundError: [Errno 2] No such file or directory: ‘python‘
问题场景
问题描述
使用ubuntu+window的环境进行编译在一步步操作下来后出现这种错误,无法编译。https://device.harmonyos.com/cn/docs/documentation/guide/ide-hi3861v100-compile-0000001192526021
[OHOS INFO] [234/358] gcc cross compiler obj/test/xts/acts/distributed_schedule_lite/system_ability_manager_hal/src/libmodule_ActsSamgrTest.iunknown_func_test.o
[OHOS INFO] [235/358] ACTION
//test/xts/acts/build_lite:acts_xdevice(//build/lite/toolchain:riscv32-unknown-elf)[OHOS INFO] [236/358] gcc cross compiler
obj/test/xts/acts/communication_lite/lwip_hal/src/libmodule_ActsLwipTest.lwip_func_test.o[OHOS ERROR] [235/358] ACTION
//test/xts/acts/build_lite:acts_xdevice(//build/lite/toolchain:riscv32-unknown-elf)[OHOS ERROR] FAILED: suites/acts/tools
[OHOS ERROR] /usr/bin/python3
…/…/…/test/xts/tools/lite/build/suite.py build_xdevice
–project_dir /home/lshen/download/code-v3.0-LTS/OpenHarmony/test/xdevice
–output_dirs /home/lshen/download/code-v3.0-LTS/OpenHarmony/out/hispark_pegasus/wifiiot_hispark_pegasus/suites/acts/tools,[OHOS ERROR] Traceback (most recent call last):
[OHOS ERROR] File “…/…/…/test/xts/tools/lite/build/suite.py”,
line 273, in[OHOS ERROR] sys.exit(main(sys.argv[1:]))
[OHOS ERROR] File “…/…/…/test/xts/tools/lite/build/suite.py”,
line 268, in main[OHOS ERROR] func()
[OHOS ERROR] File “…/…/…/test/xts/tools/lite/build/suite.py”,
line 187, in build_xdevice[OHOS ERROR] subprocess.check_call(command,
cwd=self.args.project_dir)[OHOS ERROR] File “/usr/lib/python3.8/subprocess.py”, line 359, in
check_call[OHOS ERROR] retcode = call(*popenargs, **kwargs)
[OHOS ERROR] File “/usr/lib/python3.8/subprocess.py”, line 340, in
call[OHOS ERROR] with Popen(*popenargs, **kwargs) as p:
[OHOS ERROR] File “/usr/lib/python3.8/subprocess.py”, line 858, in
init[OHOS ERROR] self._execute_child(args, executable, preexec_fn,
close_fds,[OHOS ERROR] File “/usr/lib/python3.8/subprocess.py”, line 1704, in
_execute_child[OHOS ERROR] raise child_exception_type(errno_num, err_msg,
err_filename)[OHOS ERROR] FileNotFoundError: [Errno 2] No such file or directory:
‘python’[OHOS ERROR] you can check build log in
/home/lshen/download/code-v3.0-LTS/OpenHarmony/out/hispark_pegasus/wifiiot_hispark_pegasus/build.log[OHOS ERROR] command:
“/home/lshen/download/code-v3.0-LTS/OpenHarmony/prebuilts/build-tools/linux-x86/bin/ninja
-w dupbuild=warn -C /home/lshen/download/code-v3.0-LTS/OpenHarmony/out/hispark_pegasus/wifiiot_hispark_pegasus”
failed[OHOS ERROR] return code: 1
[OHOS ERROR] execution path:
/home/lshen/download/code-v3.0-LTS/OpenHarmony
问题分析
系统环境变量中缺少了python。OpenHarmony源码编译过程中,某些过程中使用的是python,有些是python3.
问题解决
根据python -V来查询是否存在,如果不存在,可以通过以下方式设置软链接:
- 查询当前系统环境变量中python3的路径,例如{python3-path}
which python3
- 设置软链接
sudo ln -s {python3-path} /usr/bin/python
谷歌我滴神