Tensorflow - 即使安装了 Nodegyp 也无法构建
Tensorflow - Nodegyp failed to build even if it is installed
我正在尝试为演示应用程序设置 TensorFlow
但是我在构建它时遇到了一些问题 我每次 npm install @tensorflow/tfjs-node
:
都会收到以下错误
CPU-windows-2.8.1.zip
* Downloading libtensorflow
[==============================] 34893663/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/2.8.1/CPU-windows-2.8.1.zip
node-pre-gyp WARN Pre-built binaries not found for @tensorflow/tfjs-node@2.8.1 and node@12.13.0 (node-v72 ABI, unknown) (falling back to source compile with node-gy
p)
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-
to-build" "--module=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node" "--module_name=tfjs_binding"
"--module_path=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5" "--napi_version=5" "--node_abi_napi=napi" "--napi_b
uild_version=5" "--node_napi_label=napi-v5"
gyp ERR! cwd C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js bu
ild --fallback-to-build --module=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node --module_name=tfjs_binding
--module_path=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5 --napi_version=5 --node_abi_napi=napi --napi_build_version=5 -
-node_napi_label=napi-v5' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\MyUser\WebstormProjects\baseball\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\MyUser\WebstormProjects\baseball\node_modules\node-pre-gyp\bin\node-pre-gyp" "instal
l" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node
node-pre-gyp ERR! node -v v12.13.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
节点版本:12.13.0
我的操作系统是Windows
Python --版本:
Python 2.7.18
谁能告诉我我做错了什么?
更新
所以我查看了错误并发现了一个小细节:
这一行:
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/2.8.1/CPU-windows-2.8.1.zip
如果我转到那个 URL 我会正确地得到 404(或未找到的页面)
所以可能是这样?如何找到该文件?
您必须安装 python 3,使用 python 版本的 TensorFlow 将无法构建。
https://www.tensorflow.org/install
我遇到了同样的问题,当我使用 python 3
而不是 python 2
时,它对我有用。
尝试安装 Python 3.8.3
根据错误:
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/2.8.1/CPU-windows-2.8.1.zip
并且根据 this issue,看来您的先决条件安装可能存在一些问题。所以可能以下链接可以帮助您解决问题:
Error installing node-gpu(这个问题是关于gpu的,但主要问题和你的问题一样)
考虑到我的不同设置(我在 macOS Catalina 上)的价值,干净项目上的 npm install @tensorflow/tfjs-node
导致 node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
,因为工作文件夹的父级之一有名称中的空格。显然这在 2021 年仍然会发生。
转向更传统的路径解决了问题。
我正在尝试为演示应用程序设置 TensorFlow
但是我在构建它时遇到了一些问题 我每次 npm install @tensorflow/tfjs-node
:
CPU-windows-2.8.1.zip
* Downloading libtensorflow
[==============================] 34893663/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/2.8.1/CPU-windows-2.8.1.zip
node-pre-gyp WARN Pre-built binaries not found for @tensorflow/tfjs-node@2.8.1 and node@12.13.0 (node-v72 ABI, unknown) (falling back to source compile with node-gy
p)
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-
to-build" "--module=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node" "--module_name=tfjs_binding"
"--module_path=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5" "--napi_version=5" "--node_abi_napi=napi" "--napi_b
uild_version=5" "--node_napi_label=napi-v5"
gyp ERR! cwd C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js bu
ild --fallback-to-build --module=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node --module_name=tfjs_binding
--module_path=C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node\lib\napi-v5 --napi_version=5 --node_abi_napi=napi --napi_build_version=5 -
-node_napi_label=napi-v5' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\MyUser\WebstormProjects\baseball\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\MyUser\WebstormProjects\baseball\node_modules\node-pre-gyp\bin\node-pre-gyp" "instal
l" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\MyUser\WebstormProjects\baseball\node_modules\@tensorflow\tfjs-node
node-pre-gyp ERR! node -v v12.13.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
节点版本:12.13.0
我的操作系统是Windows
Python --版本: Python 2.7.18
谁能告诉我我做错了什么?
更新
所以我查看了错误并发现了一个小细节:
这一行:
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/2.8.1/CPU-windows-2.8.1.zip
如果我转到那个 URL 我会正确地得到 404(或未找到的页面)
所以可能是这样?如何找到该文件?
您必须安装 python 3,使用 python 版本的 TensorFlow 将无法构建。 https://www.tensorflow.org/install
我遇到了同样的问题,当我使用 python 3
而不是 python 2
时,它对我有用。
尝试安装 Python 3.8.3
根据错误:
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v5/2.8.1/CPU-windows-2.8.1.zip
并且根据 this issue,看来您的先决条件安装可能存在一些问题。所以可能以下链接可以帮助您解决问题:
Error installing node-gpu(这个问题是关于gpu的,但主要问题和你的问题一样)
考虑到我的不同设置(我在 macOS Catalina 上)的价值,干净项目上的 npm install @tensorflow/tfjs-node
导致 node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
,因为工作文件夹的父级之一有名称中的空格。显然这在 2021 年仍然会发生。
转向更传统的路径解决了问题。