Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-gyp unhappy with Python versions #56

Closed
RobertStewart opened this issue Apr 27, 2018 · 8 comments
Closed

node-gyp unhappy with Python versions #56

RobertStewart opened this issue Apr 27, 2018 · 8 comments
Assignees

Comments

@RobertStewart
Copy link
Contributor

When I run npm install, I get an error message because node-gyp still does not support Python 3.

> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Python executable "/Users/rstewart/anaconda3/bin/python" is v3.6.4, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

According to this long issue thread, there is some hope for Python 3 support - nodejs/node-gyp#193

To force the usage of Python 2.7, I tried npm install --python=python2.7. That produced a different error message.

> node-gyp rebuild

  CXX(target) Release/obj.target/sha3/src/addon.o
../src/addon.cpp:59:36: error: no matching member function for call to 'NewInstance'
                        info.GetReturnValue().Set(cons->NewInstance(argc, argv));
                                                  ~~~~~~^~~~~~~~~~~
/Users/rstewart/.node-gyp/10.0.0/include/node/v8.h:3851:44: note: candidate function not viable: requires single argument 'context', but 2 arguments were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                           ^
/Users/rstewart/.node-gyp/10.0.0/include/node/v8.h:3848:44: note: candidate function not viable: requires 3 arguments, but 2 were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                           ^
1 error generated.
make: *** [Release/obj.target/sha3/src/addon.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)

Any other magic incantations I should try?

@robrobbins
Copy link
Contributor

robrobbins commented Apr 27, 2018

...let's field-trip it over to Dropbox to talk to Guido about this? :p

Lemme try to recreate this. @RobertStewart is your system default Python 3 now? That looks like MacOS, Homebrewed Python? There's that one post (in the thread) about using npm set ..., concern there is that if you got gyp to use 2.7 with the flag is the set version any different?

Both my dev boxes still point to 2.7.x as 'system' py (with 3 stuff in a virtualEnv) -- I assume that's why I didn't see it

@robrobbins
Copy link
Contributor

robrobbins commented Apr 27, 2018

nodejs/node-gyp#1337 (comment)

scroll down to the comment by tmoxley. essentially

  • brew python2 if you don't already have it
  • make sure its in your path
  • npm config set python python2.7

maybe that is different that passing the argv? let me know if ^ works.

@robrobbins robrobbins self-assigned this Apr 27, 2018
@robrobbins
Copy link
Contributor

Also, @RobertStewart can you echo your $Path here?

@RobertStewart
Copy link
Contributor Author

% echo $PATH
/Users/rstewart/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Users/rstewart/bin

My system defaults to Python 3 from Anaconda due to the path above. It appears to also be using the built-in Python 2.7.

% which python2.7
/usr/bin/python2.7
Roberts-iMac:computable.js[master]% ls -l /usr/bin/python2.7
lrwxr-xr-x  1 root  wheel  75 Nov 12 12:36 /usr/bin/python2.7@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

The version for that install is Python 2.7.10 (default, Oct 6 2017, 22:29:07).

I tried npm config set python python2.7 and then npm install. Python 2.7 was used by default this time, but I got the same error message.

Since I already had a brew install of python2, Python 2.7.14 (default, Apr 25 2018, 22:48:07), I put the bin directory for that install at the front of $PATH and tried again. Same result.

In the npm logfile, my path when the script was running for this last attempt was:

7914 verbose lifecycle sha3@1.2.0~install: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/rstewart/src/computable.js/node_modules/sha3/node_modules/.bin:/Users/rstewart/src/computable.js/node_modules/.bin:/usr/local/Cellar
/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/bin:/Users/rstewart/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Users/rstewart/bin

Below is a more complete excerpt of the error message when I run npm install.

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:225:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/10.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/rstewart/src/computable.js/node_modules/sha3
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN webpack-cli@2.0.14 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3@1.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sha3@1.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@robrobbins
Copy link
Contributor

I wonder if we can focus on the sha3 package itself on your system.

@robrobbins
Copy link
Contributor

robrobbins commented Apr 29, 2018

what's your Node version? did i see 10? Use a version-manager (nvm, n) and try it with 8.11.1 - that's what i'm using on a fresh install i just did (8 being the latest LTS)

try these
0. make sure you have X-Code command line tools installed (this fixes these errors for some i guess)

  1. install and use node 8.11.1 (npm v5.6.0 is what came with node 8.11 on mine). try npm install again
  2. if still erroring try just installing the sha3 package and see if it errors - if it does it may give better error messages. this is all way down in the deps somewhere so...

@RobertStewart
Copy link
Contributor Author

Using nvm to switch to Node 8.11.1 allowed npm install to complete with a warning instead of an error.

> node-gyp rebuild

  CXX(target) Release/obj.target/sha3/src/addon.o
../src/addon.cpp:59:36: warning: 'NewInstance' is deprecated [-Wdeprecated-declarations]
                        info.GetReturnValue().Set(cons->NewInstance(argc, argv));
                                                        ^
/Users/rstewart/.node-gyp/8.11.1/include/node/v8.h:3846:3: note: 'NewInstance' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version",
  ^
/Users/rstewart/.node-gyp/8.11.1/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
1 warning generated.
  CXX(target) Release/obj.target/sha3/src/displayIntermediateValues.o
  CXX(target) Release/obj.target/sha3/src/KeccakF-1600-reference.o
  CXX(target) Release/obj.target/sha3/src/KeccakNISTInterface.o
  CXX(target) Release/obj.target/sha3/src/KeccakSponge.o
  SOLINK_MODULE(target) Release/sha3.node
npm WARN webpack-cli@2.0.14 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.

@RobertStewart
Copy link
Contributor Author

I got another problem while running tests, but since that issue is probably unrelated to this one, I'll go ahead and close it as being fixed by using to nvm to switch from Node 10.0 to 8.11.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants