OSError:[WinError 193]%1不是有效的Win32应用程序opencv.js

时间:2018-04-10 08:19:44

标签: javascript python opencv subprocess command-prompt

我尝试在其页面上PyGame构建opencv.js

我已经完成了除最后一步之外的所有步骤来构建它:

C:\Users\student>python C:\Users\student\opencv\platforms\js\build_js.py documents

这给了我这个错误:

Args: Namespace(build_dir='documents', build_doc=False, build_test=False, build_wasm=False, clean_build_dir=False, config_only=False, emscripten_dir=None, enable_exception=False, opencv_dir='C:\\Users\\student\\opencv', skip_config=False)
Cannot get Emscripten path, please specify it either by EMSCRIPTEN environment variable or --emscripten_dir option.

我尝试使用它然后

C:\Users\student>python C:\Users\student\opencv\platforms\js\build_js.py --emscripten=C:\Users\student\emsdk\emscripten\1.37.36 documents

使用--emscripten选项,但我得到了这个:

Args: Namespace(build_dir='documents', build_doc=False, build_test=False, build_wasm=False, clean_build_dir=False, config_only=False, emscripten_dir='C:\\Users\\student\\emsdk\\emscripten\\1.37.36', enable_exception=False, opencv_dir='C:\\Users\\student\\opencv', skip_config=False)
Check dir C:\Users\student\documents (create: True, clean: False)
Check dir C:\Users\student\opencv (create: False, clean: False)
Check dir C:\Users\student\emsdk\emscripten\1.37.36 (create: False, clean: False)
Traceback (most recent call last):
  File "C:\Users\student\opencv\platforms\js\build_js.py", line 215, in <module>
    builder = Builder(args)
  File "C:\Users\student\opencv\platforms\js\build_js.py", line 84, in __init__
    self.emcc_version = determine_emcc_version(self.emscripten_dir)
  File "C:\Users\student\opencv\platforms\js\build_js.py", line 62, in determine_emcc_version
    ret = subprocess.check_output([os.path.join(emscripten_dir, "emcc"), "--version"])
  File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

我已经搜索了这个问题差不多2天但没有解决它。

我使用的是Windows 10 64位。

1 个答案:

答案 0 :(得分:2)

打开opencv\platforms\js\build_js.py文件,并替换此行:

ret = subprocess.check_output([os.path.join(emscripten_dir, "emcc"), "--version"])

用这个:

ret = subprocess.check_output([os.path.join(emscripten_dir, "emcc.bat"), "--version"])

希望这将在下一个opencv版本中修复。