Skip to content
Fix Code Error

Running Python on Windows for Node.js dependencies

March 14, 2021 by Code Error
Posted By: Anonymous

I am getting into a Node.js codebase which requires that I download a few dependencies via NPM, namely jQuery.

In attempting to run npm install jquery, I keep getting this error:

Your environment has been set up for using Node.js 0.8.21 (x64) and NPM

C:UsersMatt Cashatt>npm install jquery
npm http GET https://registry.npmjs.org/jquery
npm http 304 https://registry.npmjs.org/jquery
npm http GET https://registry.npmjs.org/jsdom
npm http GET https://registry.npmjs.org/xmlhttprequest
npm http GET https://registry.npmjs.org/htmlparser/1.7.6
npm http GET https://registry.npmjs.org/location/0.0.1
npm http GET https://registry.npmjs.org/navigator
npm http GET https://registry.npmjs.org/contextify
npm http 304 https://registry.npmjs.org/htmlparser/1.7.6
npm http 304 https://registry.npmjs.org/xmlhttprequest
npm http 304 https://registry.npmjs.org/location/0.0.1
npm http 304 https://registry.npmjs.org/navigator
npm http 304 https://registry.npmjs.org/jsdom
npm http 304 https://registry.npmjs.org/contextify
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/cssom
npm http GET https://registry.npmjs.org/cssstyle
npm http GET https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/bindings

> [email protected] install C:UsersMatt Cashattnode_modulesjquerynode_module
scontextify
> node-gyp rebuild


C:UsersMatt Cashattnode_modulesjquerynode_modulescontextify>node "C:Progr
am Filesnodejsnode_modulesnpmbinnode-gyp-bin\....node_modulesnode-gypb
innode-gyp.js" rebuild
npm http 304 https://registry.npmjs.org/cssstyle
npm http 304 https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/request
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (C:Program Filesnodejsnode_modulesnpmnod
e_modulesnode-gyplibconfigure.js:113:14)
gyp ERR! stack     at C:Program Filesnodejsnode_modulesnpmnode_modulesnode
-gyplibconfigure.js:82:11
gyp ERR! stack     at Object.oncomplete (fs.js:297:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modu
les\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:UsersMatt Cashattnode_modulesjquerynode_modulescontextify
gyp ERR! node -v v0.8.21
gyp ERR! node-gyp -v v0.8.4
gyp ERR! not ok
npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'C:UsersMatt Cashattnode_
modulesjquerynode_modulesjsdomnode_modulesrequesttests'
npm ERR! error rolling back  [email protected] { [Error: ENOTEMPTY, rmdir 'C:UsersM
att Cashattnode_modulesjquerynode_modulesjsdomnode_modulesrequesttests']
npm ERR! error rolling back   errno: 53,
npm ERR! error rolling back   code: 'ENOTEMPTY',
npm ERR! error rolling back   path: 'C:\Users\Matt Cashatt\node_modules\jque
ry\node_modules\jsdom\node_modules\request\tests' }
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "jquery"
npm ERR! cwd C:UsersMatt Cashatt
npm ERR! node -v v0.8.21
npm ERR! npm -v 1.2.11
npm ERR! code ELIFECYCLE
npm ERR! Error: ENOENT, lstat 'C:UsersMatt Cashattnode_modulesjquerynode_mo
dulesjsdomnode_modulesrequestteststest-pipes.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "jquery"
npm ERR! cwd C:UsersMatt Cashatt
npm ERR! node -v v0.8.21
npm ERR! npm -v 1.2.11
npm ERR! path C:UsersMatt Cashattnode_modulesjquerynode_modulesjsdomnode_
modulesrequestteststest-pipes.js
npm ERR! fstream_path C:UsersMatt Cashattnode_modulesjquerynode_modulesjsd
omnode_modulesrequestteststest-pipes.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:Program Filesnodejsnode_modulesnpmnode_modulesfst
reamlibwriter.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:UsersMatt Cashattnpm-debug.log
npm ERR! not ok code 0

C:UsersMatt Cashatt>

It looks like the failure is due to a missing Python installation. Well, I have installed Python, set the variable, and rebooted and still the error.

Any clue as to what I am missing?

Solution

Your problem is that you didn’t set the environment variable.

The error clearly says this:

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

And in your comment, you say you did this:

set PYTHONPATH=%PYTHONPATH%;C:My_python_lib

That’s nice, but that doesn’t set the PYTHON variable, it sets the PYTHONPATH variable.


Meanwhile, just using the set command only affects the current cmd session. If you reboot after that, as you say you did, you end up with a whole new cmd session that doesn’t have that variable set in it.

There are a few ways to set environment variables permanently—the easiest is in the System Control Panel in XP, which is of course different in Vista, different again in 7, and different again in 8, but you can google for it.

Alternatively, just do the set right before the npm command, without rebooting in between.


You can test whether you’ve done things right by doing the exact same thing the config script is trying to do: Before running npm, try running %PYTHON%. If you’ve done it right, you’ll get a Python interpreter (which you can immediately quit). If you get an error, you haven’t done it right.


There are two problems with this:

set PYTHON=%PYTHON%;D:Python

First, you’re setting PYTHON to ;D:Python. That extra semicolon is fine for a semicolon-separated list of paths, like PATH or PYTHONPATH, but not for a single value like PYTHON. And likewise, adding a new value to the existing value is what you want when you want to add another path to a list of paths, but not for a single value. So, you just want set PYTHON=D:Python.

Second, D:Python is not the path to your Python interpreter. It’s something like D:PythonPython.exe, or D:PythonbinPython.exe. Find the right path, make sure it works on its own (e.g., type D:PythonbinPython.exe and make sure you get a Python interpreter), then set the variable and use it.


So:

set PYTHON=D:PythonbinPython.exe

Or, if you want to make it permanent, do the equivalent in the Control Panel.

Answered By: Anonymous

Related Articles

  • Detect if Visual C++ Redistributable for Visual Studio 2012…
  • Unexpected end of JSON input while parsing
  • Can't install via pip because of egg_info error
  • Node.js Error: Cannot find module express
  • How do I properly mock a DOM so that I can test a Vue app…
  • Reference - What does this regex mean?
  • How to download Xcode DMG or XIP file?
  • How to detect my browser version and operating system using…
  • How to update Python?
  • Get operating system info

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Start thread with member function

Next Post:

How to navigate through a vector using iterators? (C++)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error