[OHOS ERROR] FileNotFoundError: [Errno 2] No such file or directory: ‘python‘

在Ubuntu与Windows双系统环境中尝试编译OpenHarmony时遇到错误,问题源于系统缺失python环境。编译过程中部分步骤依赖python,导致编译失败。错误日志显示'python'文件未找到。解决方法是通过`which python3`查找python3的路径,并创建软链接到'/usr/bin/python',以确保编译脚本能找到python解释器。
摘要由CSDN通过智能技术生成

问题场景

问题描述

使用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

谷歌我滴神

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值