UNPKG

2.28 kBMarkdownView Raw
1# TensorFlow.js Node.js bindings Windows troubleshooting.
2
3The tfjs-node package uses the [node-gyp](https://github.com/nodejs/node-gyp) package to handle cross-compiling the C++ code required to bind TensorFlow to Node.js. This cross platform solution can be somewhat tricky on Windows platforms. This guide helps reference solutions that have been triaged through Issues on the main [tfjs repo](https://github.com/tensorflow/tfjs).
4
5## Ensure Python 2.x is installed
6
7Currently, node-gyp requires Python 2.x to work properly. If Python 3.x is installed, you will see build failures. Also double check your python version `python --version` and update the Windows `$PATH` as needed.
8
9## 'The system cannot find the patch specified' Exceptions
10
11This can happen for a variety of reasons. First, to inspect what is missing either `cd node_modules/@tensorflow/tfjs-node` or clone the [tensorflow/tfjs-node repo](https://github.com/tensorflow/tfjs-node).
12
13After `cd`'ing or cloning, run the following command (you might need node-gyp installed globablly `npm install -g node-gyp`):
14
15```sh
16node-gyp configure --verbose
17```
18
19### Missing `python2`
20
21From the verbose output, if you see something like:
22
23```sh
24gyp verb check python checking for Python executable "python2" in the PATH
25gyp verb `which` failed Error: not found: python2
26```
27
28This means that node-gyp expects a 'python2' exe somewhere in `%PATH%`. Try running this command from an Admin (elevated privilaged prompt):
29
30You can try running this from an Adminstrative prompt:
31
32```sh
33$ npm --add-python-to-path='true' --debug install --global windows-build-tools
34```
35
36### Something else?
37
38If another missing component shows up - please file an issue on [tensorflow/tfjs](https://github.com/tensorflow/tfjs/issues/new) with the output from the `node-gyp configure --verbose` command.
39
40## msbuild.exe Exceptions
41
42Check the full stack trace from `npm install` (or `yarn`) command. If you see something like:
43
44```
45gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
46```
47
48You might need to install the system tools manually. This can be done via:
49
50```
51npm install -g --production windows-build-tools
52```
53
54If that still does not work - try re-running the command above in a privileged shell.