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

python: more informative error #1269

Closed
wants to merge 1 commit into from

Conversation

@refack
Copy link
Member

commented Aug 20, 2017

Checklist
  • npm install && npm test passes
  • tests are included
  • commit message follows commit guidelines
Description of change

more informative error when failing to find a suitable python:

gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\bin\\dev\\node\\node4.exe',
gyp verb cli   'D:\\code\\4node\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'configure',
gyp verb cli   '--loglevel=verbose' ]
gyp info using node-gyp@4.0.0
gyp info using node@4.8.2 | win32 | x64
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\code\4node\node-gyp\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\code\4node\node-gyp\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\code\4node\node-gyp\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\code\4node\node-gyp\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\code\4node\node-gyp\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\code\4node\node-gyp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python2 { [Error: not found: python2]
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:13:12)\n    at F (D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:68:19)\n    at E (D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:80:29)\n    at D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:89:16\n    at D:\\code\\4node\\node-gyp\\node_modules\\isexe\\index.js:42:5\n    at D:\\code\\4node\\node-gyp\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:82:15)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (D:\code\4node\node-gyp\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\code\4node\node-gyp\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\code\4node\node-gyp\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\code\4node\node-gyp\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\code\4node\node-gyp\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\code\4node\node-gyp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python { [Error: not found: python]
gyp verb `which` failed   stack: 'Error: not found: python\n    at getNotFoundError (D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:13:12)\n    at F (D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:68:19)\n    at E (D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:80:29)\n    at D:\\code\\4node\\node-gyp\\node_modules\\which\\which.js:89:16\n    at D:\\code\\4node\\node-gyp\\node_modules\\isexe\\index.js:42:5\n    at D:\\code\\4node\\node-gyp\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:82:15)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb could not find "python". checking python launcher 
gyp verb could not find "python". guessing location 
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error 
gyp ERR! 
******************************************************************
node-gyp can't use "python",
It is recommended that you install python 2.7, set the PYTHON env,
or use the --python switch to point to a Python >= v2.6.0 & < 3.0.0.
For more information consult the documentation at:
https://github.com/nodejs/node-gyp#installation
*********************************************************************** 
gyp ERR! not ok 
@refack

This comment has been minimized.

this.callback(new Error(errmsg))
const err = new Error(
'\n******************************************************************\n' +
`node-gyp can't use "${this.python}",\n` +

This comment has been minimized.

Copy link
@richardlau

richardlau Aug 20, 2017

Member

Did you mean to change the wording from "can't find" to "can't use"?

This comment has been minimized.

Copy link
@refack

refack Aug 20, 2017

Author Member

Yes because this error is printed both when python can't be found, and on windows when it's a bad version.
In #1268 the error outputed was:

stack Error: Can't find Python executable "C:\Program Files\Python35\python.EXE", you can set the PYTHON env variable.

which makes less sense.

This comment has been minimized.

Copy link
@richardlau

richardlau Aug 20, 2017

Member

Is it possible to distinguish between "can't be found" and bad version? In the example output in the PR description (i.e. the not found case), I think the message is now worse.

node-gyp can't use "python",

This comment has been minimized.

Copy link
@refack

refack Aug 20, 2017

Author Member

It's quite convoluted code...
I'll give it another look in the morning but I can't promise I can find an elegant solution. This code comes after several rounds of geusses so it difficult to know what was found but deemed unsuitable or if nothing was found at all.

This comment has been minimized.

Copy link
@mvidmar

mvidmar Nov 5, 2017

Didn't notice this PR before doing my own fix. Solves the above issue and detects if there is a wrong version + a possible infinite loop fix. See #1325

@jeanru

This comment has been minimized.

Copy link

commented Sep 7, 2017

+1, I have similar issue, and the error info is as following:

C:\Program Files (x86)\Microsoft Visual Studio 11.0>npm config set python "D:/Python27/python.exe"

C:\Program Files (x86)\Microsoft Visual Studio 11.0>node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.0.0 | win32 | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\leon\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\leon\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Users\leon\AppData\Roaming\npm\node_modules\node-gyp\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\leon\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files (x86)\Microsoft Visual Studio 11.0
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
@mvidmar mvidmar referenced this pull request Nov 5, 2017
2 of 4 tasks complete
@ncannasse

This comment has been minimized.

Copy link

commented Apr 8, 2018

This should be definitely merged, the error message is vastly misleading. I just spent one hour figuring that I had the wrong python version installed.

@David-OConnor

This comment has been minimized.

Copy link

commented Jun 1, 2018

Same

@Bertware

This comment has been minimized.

Copy link

commented Jul 12, 2018

@bnoordhuis can someone please take a look at these python related PR's?

@@ -461,7 +461,7 @@ PythonFinder.prototype = {
this.log.silly('stripping "rc" identifier from version')
version = version.replace(/rc(.*)$/ig, '')
}
var range = semver.Range('>=2.5.0 <3.0.0')
var range = semver.Range('>=2.6.0 <3.0.0')

This comment has been minimized.

Copy link
@cclauss

cclauss Jul 23, 2018

Contributor

Should this be 2.7.0 instead of 2.6.0 at this point? Python 2.6 has been EOL for 5 years.

'\n******************************************************************\n' +
`node-gyp can't use "${this.python}",\n` +
'It is recommended that you install python 2.7, set the PYTHON env,\n' +
'or use the --python switch to point to a Python >= v2.6.0 & < 3.0.0.\n' +

This comment has been minimized.

Copy link
@cclauss

cclauss Jul 23, 2018

Contributor

Should this be 2.7.0 instead of 2.6.0 at this point? Python 2.6 has been EOL for 5 years.

`Python executable "${this.python}" is v${badVersion}\n` +
'this version is not supported by GYP and hence by node-gyp.\n' +
'It is recommended that you install python 2.7, set the PYTHON env,\n' +
'or use the --python switch to point to a Python >= v2.6.0 & < 3.0.0.\n' +

This comment has been minimized.

Copy link
@cclauss

cclauss Jul 23, 2018

Contributor

Should this be 2.7.0 instead of 2.6.0 at this point? Python 2.6 has been EOL for 5 years.

@rvagg

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

@refack I'm going to have to defer to you on the status of this and its suitability for merging, can you review and see if it's ready or not?

joaocgreis added a commit to JaneaSystems/node-gyp that referenced this pull request Oct 25, 2018
@joaocgreis joaocgreis referenced this pull request Oct 26, 2018
3 of 3 tasks complete
Copy link
Member

left a comment

Included this commit as part of #1582, so the two PRs should land simultaneously. LGTM in case you want to go ahead with this independently.

joaocgreis added a commit that referenced this pull request Nov 13, 2018
PR-URL: #1269
Refs: #1582
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
@joaocgreis

This comment has been minimized.

Copy link
Member

commented Nov 13, 2018

Landed in 6b7c8e6

@joaocgreis joaocgreis closed this Nov 13, 2018
rvagg added a commit that referenced this pull request Apr 24, 2019
PR-URL: #1269
Refs: #1582
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
@rvagg rvagg referenced this pull request Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.