问题:
编译的时候发现报错,编译失败:
scons: *** SCons version 2.4.1 does not run under Python version 3.8.0.
Python 3 is not yet supported.
Traceback (most recent call last):
File "../../build/lite/build_ext_components.py", line 64, in <module>
sys.exit(main())
File "../../build/lite/build_ext_components.py", line 58, in main
cmd_exec(args.command)
File "../../build/lite/build_ext_components.py", line 32, in cmd_exec
raise Exception("{} failed, return code is {}".format(cmd, ret_code))
Exception: ['sh', 'hm_build.sh'] failed, return code is 1
ninja: build stopped: subcommand failed.
you can check build log in /home/pjw/HarmonyOS/BearPi-HM_Nano/out/BearPi-HM_Nano/build.log
/home/pjw/HarmonyOS/tools/ninja/ninja -w dupbuild=warn -C /home/pjw/HarmonyOS/BearPi-HM_Nano/out/BearPi-HM_Nano failed, return code is 1
使用 scons -v 命令查询也报错:
原因:
不支持最新版python3.8.0
解决:
(1)安装 scons-4.0.0:
tar -xvf scons-4.0.0.tar.gz && cd SCons-4.0.0
sudo python3 setup.py install
或者
sudo python3.8 setup.py install //注意python版本
(2)查询版本:
scons -v
SCons by Steven Knight et al.:
SCons: v4.0.0.ad3f21fbf0667f5b654771176d29dbdf75d9b120, 2020-07-06 15:58:10, by bdbaddog on ProDog2020
SCons path: ['/usr/local/lib/python3.8/site-packages/SCons-4.0.0-py3.8.egg/SCons']
Copyright (c) 2001 - 2020 The SCons Foundation
(3)如果查询的版本仍然是 2.4.1,是因为默认使用之前安装的版本,使用以下方法切换::
sudo rm /usr/bin/scons
sudo ln -s /usr/local/python/bin/scons /usr/bin/scons
解决方法记录:
期间再次安装 scons 无效
sudo python -m pip install scons