58
votes

I'm trying to run the following command: npm install -g bower gulp cordova ionic tsd@next karma-cli protractor node-gyp coffee-script js-beautify typescript npm-check

I have installed Python, Visual Studio Express and node-gyp so thought I'd be good to go, however I get the following errors:

enter image description here

Regarding the "Can't find Python executable "python", you can set the PYTHON env variable." error, I'm a little confused because I have set the PYTHON environmental variable like so:

enter image description here

Any ideas please?

10
Is there an underscore in your actual path? - Padraic Cunningham
Thanks @PadraicCunningham, yes there is i.imgur.com/1kuv8Pw.png - Nick
Can you post the full evn exactly as you have it set? You can also add it to your PATH - Padraic Cunningham
Set it to your folder with the executable, C:\Program Files\Python_2.7.10 or add to your PATH stackoverflow.com/a/4855685/2141635 under system variables - Padraic Cunningham
no prob, you're welcome. You can add and accept an answer that worked for you - Padraic Cunningham

10 Answers

26
votes

You got to add python to your PATH variable. One thing you can do is Edit your Path variable now and add

;%PYTHON%;

Your variable PYTHON should point to the root directory of your python installation.

85
votes

Try:

Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator).

https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#environment-setup-and-configuration

19
votes

Just run below command with admin access

npm install --global --production windows-build-tools

15
votes

I installed python2.7 to solve this issue. I wish can help you.

9
votes

The easiest way is to let NPM do everything for you,

npm --add-python-to-path='true' --debug install --global windows-build-tools
3
votes

You are running the Command Prompt as an admin. You have only defined PYTHON for your user. You need to define it in the bottom "System variables" section.

Also, you should only point the variable to the folder, not directly to the executable.

3
votes

One of the following solutions will work for you:

  1. npm config set python c:\Python\27\python.exe or set PYTHON=D:\Python\bin\Python.exe
  2. npm config set python D:\Library\Python\Python27\python.exe
  3. Let npm configure everything for you (takes forever to complete) npm --add-python-to-path='true' --debug install --global windows-build-tools (Must be executed via "Run As Administrator" PowerShell)

If not... Try to install the required package on your own (I did so, and it was node-sass, after installing it manually, the whole npm install was successfully completed

1
votes

I have recently encountered this issue in a dockerfile using node:16-alpine as base image. I have added following run command to fix the issue:

FROM node:alpine as build-stage
RUN apk add --no-cache python3 py3-pip make g++

Here, both tags node:alpine & node:16-alpine are same.

0
votes

My Problem was the usage of Node v16.

I went back to Node v12 (v14 is probably fine as well) and it worked.