Failed while installing tfjs-node using macOS and node-gyp rebuild failed - tensorflow

I'm trying to install tfjs-node via npm install #tensorflow/tfjs-node on my mac.
I'm getting following error while trying to installing it.
Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/ReffasCode/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:389:11)
gyp ERR! stack at Socket.emit (events.js:189:13)
gyp ERR! stack at Pipe._handle.close (net.js:597:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ReffasCode/Desktop/ip2_ss19/Server/node_modules/#tensorflow/tfjs-node
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

OK, getting more information from https://github.com/nodejs/node-gyp it seems like node-gyp is not supporting Python version 3.x.x is not supported.
So if you having the same error try to specify which Python version to use:
npm config set python /usr/bin/python

Related

react-native raises weird python error when initing app

I just typed npx react-native init cinetogo, and I got this error:
stw041269:mobile hugovillalobos$ npx react-native init cinetogo
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/hugovillalobos/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:389:11)
gyp ERR! stack at Socket.emit (events.js:198:13)
gyp ERR! stack at Pipe._handle.close (net.js:606:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/hugovillalobos/.nvm/versions/node/v10.16.0/bin/node" "/Users/hugovillalobos/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/hugovillalobos/.npm/_npx/19812/lib/node_modules/react-native/node_modules/fsevents
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
I haven't found any reference to anybody with the same error,
According to this answer,
Node.js is built with GYP
and According to this answer,
node uses some python scripts under the hood, though Node is largely written in C++
The problem in your case is that you've installed Anaconda version 3 which has python 3.x installed. But for Node needs python 2.x to work with GYP.
As you can see in the log, there is some syntax error:
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
The print statement uses the syntax of Python 2.x, but your anaconda has python 3.x. So it throws Syntax Error.
Solution: Install python 2.x (2.6 or 2.7), either by installing anaconda 2 or a standalone python 2.x version, and then try to execute npx.

NPM configure error due to Homebrew Python Install

I recently installed conda via Homebrew on my machine and I noticed that every time I run npm install commands, npm is triggering an error that references a python command from my conda directory, but the install finished with success. Has anyone faced this issue and know how to prevent the error message from being triggered every time?
Here is an example:
npm i webpack -g
/Users/user/.nvm/versions/node/v10.16.1/bin/webpack -> /Users/user/.nvm/versions/node/v10.16.1/lib/node_modules/webpack/bin/webpack.js
> fsevents#1.2.11 install /Users/user/.nvm/versions/node/v10.16.1/lib/node_modules/webpack/node_modules/fsevents
> node-gyp rebuild
Then the Python is triggered:
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/local/Caskroom/miniconda/base/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:389:11)
gyp ERR! stack at Socket.emit (events.js:198:13)
gyp ERR! stack at Pipe._handle.close (net.js:606:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/user/.nvm/versions/node/v10.16.1/bin/node" "/Users/user/.nvm/versions/node/v10.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/.nvm/versions/node/v10.16.1/lib/node_modules/webpack/node_modules/fsevents
gyp ERR! node -v v10.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 (node_modules/webpack/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
And finally the package install was successful:
+ webpack#4.41.4
added 1 package from 1 contributor, removed 1 package and updated 34 packages in 11.622s

unable to install skpm on Mac

I am unable to install SKPM on mac using the following command
npm install -g skpm
here is the output
npm install -g skpm
/Users/new/.npm-global/bin/skpm -> /Users/new/.npm
global/lib/node_modules/skpm/lib/index.js > keytar#4.3.0 install /Users/new/.npm-global/lib/node_modules/skpm/node_modules/keytar >
prebuild-install || node-gyp rebuild
prebuild-install WARN install No prebuilt binaries found (target=11.1.0 runtime=node arch=x64 platform=darwin)
gyp ERR! configure error
gyp ERR! stack Error: Command failed:
/Users/new/anaconda/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:289:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:387:11)
gyp ERR! stack at Socket.emit (events.js:182:13)
gyp ERR! stack at Pipe._handle.close (net.js:611:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/node/11.1.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/new/.npm- global/lib/node_modules/skpm/node_modules/keytar
gyp ERR! node -v v11.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keytar#4.3.0 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keytar#4.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/new/.npm/_logs/2018-11-11T01_39_22_458Z-debug.log
I have Xcode and command line tools installed and OSX version is 10.13.6.
not sure how to fix this.

Error gyp when install protractor

When i try install
npm i protractor
I have error. I have install
msvs_version 2015
GYP_MSVS_VERSION=2015
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(514,5): error MSB8008: Specified platform too lset (v140) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected. [D:\Projects\angularjs\no de_modules\utf-8-validate\build\validation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\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:270:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Projects\angularjs\node_modules\utf-8-validate
gyp ERR! node -v v5.5.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
Make sure that you satisfied all the steps listed here https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#prerequisites
Afterwards if it still doesn't work try
node-gyp configure --msvs_version=2015
or the npm example
npm install --msvs_version=2015

Error while trying to install ursa with npm

I have this error when i try to install ursa (RSA public/private key OpenSSL bindings for node and io.js)
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.19.0-39-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/saad/Bureau/kevinIdP/node_modules/ursa
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! weird error 1
npm ERR! not ok code 0
Do i have to add some dependencies ?
Thanks for the interest