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
Contributor

@refack refack 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
Copy link
Contributor Author

refack commented Aug 20, 2017

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

jeanru 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

@ncannasse
Copy link

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
Copy link

Same

@Bertware
Copy link

@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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rvagg
Copy link
Member

rvagg 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 pushed a commit to JaneaSystems/node-gyp that referenced this pull request Oct 25, 2018
@joaocgreis joaocgreis mentioned this pull request Oct 26, 2018
3 tasks
Copy link
Member

@joaocgreis joaocgreis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pushed 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
Copy link
Member

Landed in 6b7c8e6

@joaocgreis joaocgreis closed this Nov 13, 2018
rvagg pushed 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 mentioned 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
Development

Successfully merging this pull request may close these issues.

10 participants