相关文章推荐
腼腆的柠檬  ·  python ...·  2 周前    · 
有情有义的大白菜  ·  python ...·  2 周前    · 
完美的馒头  ·  python QTreeWidget ...·  2 周前    · 
失眠的烤红薯  ·  python qt textBrowser ...·  2 周前    · 
礼貌的鸡蛋面  ·  RuoYi v4.2 ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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:

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:

Any ideas please?

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 Dec 19, 2015 at 16:08

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

This did the trick on my behalf. Pretty annoying though that it will install Python 2.7 as I don't want to soil my environment with a Python version that I'm not going to use. bork Aug 31, 2018 at 8:56 Fixed this error, and probably others I haven't hit yet. Going into the list of dev machine setup steps! Natasha Voloshyna May 28, 2021 at 1:40

https://github.com/nodejs/node-gyp#on-windows

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

npm config set python D:\Library\Python\Python27\python.exe
                @ZhangBuzz It's because the gyp tool that node-gyp depends on was written for Python 2 and is not compatible with Python 3.
– Shweta Gupta
                Jul 29, 2019 at 10:27
                2021 here, they still want it aaand the 2.7 cannot be installed due to bug (endless cycle).
– tequilacat
                Feb 19, 2021 at 18:18
                @LachoTomov get out of the waterfall cycle its agile world, patches and version upgrades are required for fixing bugs and exploits or loose your bitcoin wallets to hippies
– MDT
                Jul 6, 2022 at 10:06

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.

Thank you, I've set the PYTHON path to C:\Program Files\Python_2.7.10;%PYTHON%; but I'm still getting the same error unfortunately – Nick Dec 19, 2015 at 16:24 Actually you want to set your python path to C:\Program Files\Python_2.7.10 and then edit your PATH Variable and add ;%PYTHON; . I've looked it up locally and i added C:\Python34;C:\Python34\Scripts; to get things working. Although as you see im not using Python 2. – jvecsei Dec 19, 2015 at 16:27 Actually this post: stackoverflow.com/a/21433154/3378288 describes exactly what i was trying to explain but in a more detailed way ;). For you to note: it's not important if your path variable is PY_HOME, or PYTHON. It's just important that it matches with what you insert in your path variable. – jvecsei Dec 19, 2015 at 16:29 omg... I didn't realise I had to close the command window for the new variables to be in play. Thank you all so much for the replies and advice! – Nick Dec 19, 2015 at 17:08 Installing Python2.7.10 and setting the PATH and PYTHON environment variables successfully resolved the issue. Thanks you @jvecsei – Jnana Aug 22, 2018 at 9:02 Don't think this is merged in yet, and it didn't work on this end - github.com/nodejs/node-gyp/pull/1109 – Daniel Sokolowski May 29, 2019 at 4:03

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.

This one introduce more errors like ` Missing parentheses in call to 'print'. Did you mean print` – Simon Peter Ojok Mar 25 at 11:27
  • npm config set python c:\Python\27\python.exe or set PYTHON=D:\Python\bin\Python.exe
  • npm config set python D:\Library\Python\Python27\python.exe
  • 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

    First installing node-sass manually actually worked for me. Had been struggling with python thing. – sangam Feb 24, 2021 at 19:27

    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.

    Thank you, I've added C:\Program Files\Python_2.7.10;%PYTHON%; in as the PYTHON variable under System variables and unfortunately am still getting the same error :( – Nick Dec 19, 2015 at 16:29 As mentioned in the other comments, %PYTHON% should go in the PATH variable, not PYTHON. By adding it in PYTHON, you are making a circular reference, which is not good for your computer. – OneCricketeer Dec 19, 2015 at 16:32 Thank you, have just changed PYTHON and included it in the PATH variable and still getting the same error. Argh :( – Nick Dec 19, 2015 at 16:39

    Had this issue on node:18 alpine docker image on Apple Silicon where only python3 is available but at least some versions of node-gyp don't support pyhton3 yet. So I had to use an alpine version that still had python2:

    FROM node:18.8.0-alpine3.15
    WORKDIR /app
    RUN apk --no-cache add python2 make g++
    COPY package.json .
    COPY yarn.lock .
    RUN yarn
    COPY . .
    
    npm config set python D:\Library\Python\Python27\python.exe
    

    This kind off worked for me from Tom Gao's answer

    Make sure to change in npmrc file as it doesnt automatically takes \ for the path and do add Python in env var also as mentioned in the answers.

    This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – Caspar V. Jun 26, 2022 at 23:17 This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – hide1nbush Nov 7, 2022 at 8:00