15

Below is the error that I get, when I try to generate a new project with JHipster:

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Program Files\Python36\python.EXE
gyp verb check python version `C:\Program Files\Python36\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.4\r\n"
gyp verb could not find "C:\Program Files\Python36\python.EXE". checking python launcher
gyp verb could not find "C:\Program Files\Python36\python.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files\Python36\python.EXE", you can set the PYTHON env variable.

The rest is the stacktrace. The weird thing is I do have python installed and the environment variable is also set. My python version is "Python 3.6.4". Should I run it in Python 2? Is that the case?

leventunver
  • 3,269
  • 7
  • 24
  • 39

5 Answers5

14

Yes node-gyp requires Python 2.7, so you could try the answers to this question.

Alternatively, if you encounter this problem, it is probably due to node-sass and if you did not select Sass in JHipster options, you don't need it but still you get it because it's a transitive dependency from Angular, you can skip it by setting environment variables:

set SKIP_SASS_BINARY_DOWNLOAD_FOR_CI=true
set SKIP_NODE_SASS_TESTS=true

Another alternative is to use JHipster devbox.

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49
11

There is another workaround to this error:

  1. Delete your node_modules folder.
  2. Run npm install --global windows-build-tools --save in your command prompt.
  3. Install node-sass using the command: npm install node-sass@4.12.0 --save (or the latest version)

This should solve the error and return you a gyp info ok message!

If you encounter Node Sass could not find a binding for your current environment, resolve it by running:

npm rebuild node-sass

Steffi Keran Rani J
  • 3,667
  • 4
  • 34
  • 56
  • Is windows-build-tools still a valid solution these days? Getting `npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.` – Jake Aug 03 '23 at 16:19
7

Just a note for anyone using React and facing the same error on Linux (Ubuntu):

Step 1: Install python 2.7

  • something similar to this
     sudo apt update
     sudo apt install python2-minimal
    

Step 2: Install make or just build-essential

  • something like:
    sudo apt-get install build-essential
    

Then you can proceed with your previous activity...

briancollins081
  • 845
  • 9
  • 19
1

I just ran into this as well.

scouty
  • 145
  • 1
  • 10
  • 1
    This still seems relevant in 2021 on pretty up-to-date installations and versions of packages. Not sure why the underlying issue is not being fixed. – MadPhysicist Jun 01 '21 at 12:19
1

I had to change to older node version:

PS C:\> nvm list

    17.6.0
  * 16.13.2 (Currently using 64-bit executable)
    15.0.0
    10.19.0
PS C:\> nvm use 10.19.0
Now using node v10.19.0 (64-bit)

Otherwise package node-sass failed to install. I did not investigate further why.

gtu
  • 707
  • 1
  • 10
  • 22