WebAssembly 编译错误 a bytes-like object is required, not 'str'

yufei       5 年, 6 月 前       1262

虽然 WebAssembly 的编译脚本已经对 Python2Python3 作出了区别,但在某些地方,尤其是使用到字符串的地方却没有作出分别

例如 ./emsdk install sdk-incoming-64bit binaryen-master-64bit 安装 WebAssembly 就会出错

Installing SDK 'sdk-incoming-64bit'..
Installing tool 'clang-incoming-64bit'..
Repository 'https://github.com/kripken/emscripten-fastcomp.git' already cloned to directory '/Users/yufei/Downloads/emsdk/clang/fastcomp/src', skipping.
Fetching latest changes to the branch 'incoming' for '/Users/yufei/Downloads/emsdk/clang/fastcomp/src'...
Already up-to-date.
Successfully updated and checked out branch 'incoming' on repository '/Users/yufei/Downloads/emsdk/clang/fastcomp/src'
Current repository version: "Mon, 3 Sep 2018 19:19:25 -0700 49340ac23ed3065116323699f0c44498d5f15d37"
Repository 'https://github.com/kripken/emscripten-fastcomp-clang.git' already cloned to directory '/Users/yufei/Downloads/emsdk/clang/fastcomp/src/tools/clang', skipping.
Fetching latest changes to the branch 'incoming' for '/Users/yufei/Downloads/emsdk/clang/fastcomp/src/tools/clang'...
Already up-to-date.
Successfully updated and checked out branch 'incoming' on repository '/Users/yufei/Downloads/emsdk/clang/fastcomp/src/tools/clang'
Current repository version: "Mon, 3 Sep 2018 19:19:37 -0700 c0a68f4121de3f6fb2f2a503e89d1b0e5cdf68a9"
Traceback (most recent call last):
  File "./emsdk", line 803, in xcode_sdk_version
    return subprocess.check_output(['xcrun', '--show-sdk-version']).strip().split('.')
TypeError: a bytes-like object is required, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./emsdk", line 2385, in <module>
    sys.exit(main())
  File "./emsdk", line 2368, in main
    success = tool.install()
  File "./emsdk", line 1351, in install
    success = tool.install()
  File "./emsdk", line 1361, in install
    success = build_llvm_tool(self)
  File "./emsdk", line 856, in build_llvm_tool
    if OSX and (not os.environ.get('LLVM_CMAKE_ARGS') or not 'HAVE_FUTIMENS' in os.environ.get('LLVM_CMAKE_ARGS')) and xcode_sdk_version() < [10,13]:
  File "./emsdk", line 805, in xcode_sdk_version
    return subprocess.checkplatform.mac_ver()[0].split('.')
AttributeError: module 'subprocess' has no attribute 'checkplatform'

这个错误看起来是因为 subprocess 模块缺少 checkplatform 所致,实际上是因为 subprocess.check_output(['xcrun', '--show-sdk-version']).strip().split('.') 造成的

因为这个调用没有区分 Python2Python3 ,修复方法也很简单,就是将这句改成

if sys.version_info >= (3,):
    return subprocess.check_output(['xcrun', '--show-sdk-version']).decode('utf8').strip().split('.')
else:
    return subprocess.check_output(['xcrun', '--show-sdk-version']).strip().split('.')

因为这个改动,然后下面还会继续报错

TypeError: '<' not supported between instances of 'str' and 'int'

需要将

xcode_sdk_version() < [10,13]

改成

xcode_sdk_version() < ['10','13']

其它情况下,如果不出错,应该就能编译通过了

目前尚无回复
简单教程 = 简单教程,简单编程
简单教程 是一个关于技术和学习的地方
现在注册
已注册用户请 登入
关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.