0

问题:

基本上我无法为节点安装最新版本的 tensorflow(npm install @tensorflow/tfjs-node)。

主要关心:

我可以使用哪些版本的 node.js、node-gyp、node-pre-gyp、visual studio code 和 python?

作为能够重现错误的以下步骤:

我用 c++ 包(2017 和 2019)安装了 Visual Studio 社区

我安装了 python 3.10.1

节点gyp配置--msvs_version=2017

npm i -g 节点-gyp

npm i -g @mapbox/node-pre-gyp

我也尝试过以下方法:

npm install --python=python2.7 npm config set python python2.7

但是,这个版本的 node-gyp 似乎不支持 python 2.7

错误:

npm ERR! code 1
npm ERR! path C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/install.js
npm ERR! CPU-windows-3.12.0.zip
npm ERR! https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.7.0.zip
npm ERR! node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.4
npm ERR! node-pre-gyp info using node@16.13.1 | win32 | x64
npm ERR! node-pre-gyp info check checked for "C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node" (not found)
npm ERR! node-pre-gyp http GET https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.12.0/CPU-windows-3.12.0.zip
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.12.0/CPU-windows-3.12.0.zip
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for @tensorflow/tfjs-node@3.12.0 and node@16.13.1 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.12.0/CPU-windows-3.12.0.zip
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.1 | win32 | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.1 found at "C:\Users\Javi\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp info find VS using VS2017 (15.9.28307.1759) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\Javi\AppData\Local\Programs\Python\Python310\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'C:\Users\Javi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'msvs',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules\@tensorflow\tfjs-node\build\config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\Users\Javi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\Users\Javi\AppData\Local\node-gyp\Cache\16.13.1\include\node\common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=C:\Users\Javi\AppData\Local\node-gyp\Cache\16.13.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\Users\Javi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\Users\\Javi\\AppData\\Local\\node-gyp\\Cache\\16.13.1\\<(target_arch)\\node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules\@tensorflow\tfjs-node',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules\@tensorflow\tfjs-node\build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.1 | win32 | x64
npm ERR! gyp info spawn C:/Program Files (x86)/MSBuild/14.0/Bin
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'build/binding.sln',
npm ERR! gyp info spawn args '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args '/nologo',
npm ERR! gyp info spawn args '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! UNCAUGHT EXCEPTION
npm ERR! gyp ERR! stack Error: spawn C:/Program Files (x86)/MSBuild/14.0/Bin ENOENT
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
npm ERR! gyp ERR! stack at onErrorNT (node:internal/child_process:477:16)
npm ERR! gyp ERR! stack at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Javi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules\@tensorflow\tfjs-node\lib\napi-v8" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=8" "--node_napi_label=napi-v8"
npm ERR! gyp ERR! cwd C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Javi\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node --module_name=tfjs_binding --module_path=C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node\lib\napi-v8 --napi_version=8 --node_abi_napi=napi --napi_build_version=8 --node_napi_label=napi-v8' (7)
npm ERR! node-pre-gyp ERR! stack at ChildProcess. (C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node\node_modules@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19043
npm ERR! node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules\@tensorflow\tfjs-node\node_modules\@mapbox\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:\Users\Javi\Documents\GitHub\AI_ATest_Composer\node_modules@tensorflow\tfjs-node
npm ERR! node-pre-gyp ERR! node -v v16.13.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.4
npm ERR! node-pre-gyp ERR! not ok
npm ERR! * Downloading libtensorflow
npm ERR!
npm ERR! * Building TensorFlow Node.js bindings

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Javi\AppData\Local\npm-cache_logs\2022-01-07T13_43_16_353Z-debug-0.log

我试过的:

我几乎可以肯定这一定是版本的问题,我尝试了不同的组合。

我尝试使用 Visual Studio 代码 2015、2017 和 2019。(尝试 node-gyp 配置 --msvs_version=2019 时,2019 给我一个错误)。同样使用 node-gyp 的最新版本和 3.8.0,因为在某些帖子中我读到它对某人有用,我也尝试使用过时的 node-pre-gyp 版本以及@mapbox/node-pre 的最新版本-吉普。所有这些都在节点 16.13.1 中。

在其他版本的节点中,我还尝试使用 python 2.7 使用 2015 年的 Visual Studio,因为在某些帖子中它似乎是一个可能的解决方案。

目前我什至不知道我尝试了多少其他东西,因为我已经尝试了两个星期。最后,我决定发这个帖子寻求帮助。

系统信息:

-Windows 10 x64
-node version 16.13.1 (the current recommended in node js webpage)
-visual studio community 2017 and 2019 installed
-python version 2.7 and 3.10.1 installed
-@tensorflow/tfjs 3.12.0
-@mapbox/node-pre-gyp 1.0.8
-node-gyp 8.4.1
4

1 回答 1

0

显然,该版本的 tfjs-node 似乎存在问题。降级它工作并且也在ubuntu上运行它。

于 2022-02-22T11:33:53.500 回答