LookupError: unknown encoding: string_escape when running scons command

LookupError: unknown encoding: string_escape when running scons command

我正在按照本教程构建 IoTivity 基础 Android API:

https://wiki.iotivity.org/android_build_instructions#android_example_apps

我从这里下载了 IoTivity 项目:

https://iotivity.org/downloads

我正处于使用命令为 Android 构建 IoTivity 的步骤:

scons TARGET_OS=android

我得到输出:

scons: Reading SConscript files ... LookupError: unknown encoding:
string_escape:   File
"C:\Users\Darius\Downloads\iotivity-1.3.1.tar\iotivity-1.3.1\iotivity-1.3.1\SConstruct",
line 28:
    SConscript('build_common/SConscript')   File "c:\users\darius\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Script\SConscript.py",
line 667:
    return method(*args, **kw)   File "c:\users\darius\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Script\SConscript.py",
line 604:
    return _SConscript(self.fs, *files, **subst_kw)   File "c:\users\darius\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Script\SConscript.py",
line 285:
    call_stack[-1].globals)   File "C:\Users\Darius\Downloads\iotivity-1.3.1.tar\iotivity-1.3.1\iotivity-1.3.1\build_common\SConscript",
line 559:
    user_prefix = env.get('BUILD_DIR').encode('string_escape')

我在 Windows 机器上,使用命令提示符。

我尝试了post中的解决方案:

但这并没有帮助。我是 Python 的新手。有人可以帮忙吗?

编辑

更改为 Python 2.7.16 后,我现在得到以下输出:

scons: Reading SConscript files ...

*********************** Error ************************
*                                                    *
* Please make sure that 7-zip is in your System PATH *
*                                                    *
******************************************************

NameError: name 'host_arch' is not defined:   File
"C:\Users\Darius\Downloads\iotivity-1.3.1.tar\iotivity-1.3.1\iotivity-1.3.1\SConstruct",
line 28:
    SConscript('build_common/SConscript')   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
667:
    return method(*args, **kw)   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
604:
    return _SConscript(self.fs, *files, **subst_kw)   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
285:
    call_stack[-1].globals)   File "C:\Users\Darius\Downloads\iotivity-1.3.1.tar\iotivity-1.3.1\iotivity-1.3.1\build_common\SConscript",
line 795:
    env.SConscript(target_os + '/SConscript')   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
604:
    return _SConscript(self.fs, *files, **subst_kw)   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
285:
    call_stack[-1].globals)   File "C:\Users\Darius\Downloads\iotivity-1.3.1.tar\iotivity-1.3.1\iotivity-1.3.1\build_common\android\SConscript",
line 19:
    SConscript('#/extlibs/android/ndk/SConscript')   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
667:
    return method(*args, **kw)   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
604:
    return _SConscript(self.fs, *files, **subst_kw)   File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line
285:
    call_stack[-1].globals)   File "C:\Users\Darius\Downloads\iotivity-1.3.1.tar\iotivity-1.3.1\iotivity-1.3.1\extlibs\android\ndk\SConscript", line 24:
    if host_arch in ['x86_64']:

我确实将我的 7-zip 文件夹路径添加到 PATH 环境变量并重新启动,但我仍然收到此消息。虽然不确定为什么需要它..

查看错误,似乎 iotivity 使用的 string_escape 在 python 3.*.

下不受支持

您需要安装 python 2.7 然后:

py -3 -mpip uninstall scons
py -2 -mpip install -U pip setuptools wheel
py -2 -mpip install scons

然后重试。