Error when trying to install modules in NodeJS: "Error: Can not find Python executable" python ", you can set the PYT HON env variable."

5

When I try to install the modules I need, it returns several errors at the time of installation (in this case I tried to install socket.io):

MicrosoftWindows[versão6.3.9600](c)2013MicrosoftCorporation.Todososdireitosreservados.C:\Users\IvanSilva>npminstallsocket.io\>[email protected]:\Users\IvanSilva\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate>node-gyprebuildC:\Users\IvanSilva\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate>ifnotdefinednpm_config_node_gyp(node"C:\nodej
s\node_modules\npm\bin\node-gyp-bin\..\..\node_modules\node-gyp\bin\node-gyp.js
" rebuild )  else (node  rebuild )
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:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:114:14)
gyp ERR! stack     at C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:69:11
gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\nodejs\node_modules\npm\node_modules\node-gyp\
bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Ivan Silva\node_modules\socket.io\node_modules\engine.io\n
ode_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok

> [email protected] install C:\Users\Ivan Silva\node_modules\socket.io\node_modul
es\engine.io\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild


C:\Users\Ivan Silva\node_modules\socket.io\node_modules\engine.io\node_modules\w
s\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\nodejs\no
de_modules\npm\bin\node-gyp-bin\..\..\node_modules\node-gyp\bin\node-gyp.js" re
build )  else (node  rebuild )
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:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:114:14)
gyp ERR! stack     at C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:69:11
gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\nodejs\node_modules\npm\node_modules\node-gyp\
bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Ivan Silva\node_modules\socket.io\node_modules\engine.io\n
ode_modules\ws\node_modules\bufferutil
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]

> [email protected] install C:\Users\Ivan Silva\node_modules\socket.io\node_m
odules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modul
es\utf-8-validate
> node-gyp rebuild


C:\Users\Ivan Silva\node_modules\socket.io\node_modules\socket.io-client\node_mo
dules\engine.io-client\node_modules\ws\node_modules\utf-8-validate>if not define
d npm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\..\..\
node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
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:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:114:14)
gyp ERR! stack     at C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:69:11
gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\nodejs\node_modules\npm\node_modules\node-gyp\
bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Ivan Silva\node_modules\socket.io\node_modules\socket.io-c
lient\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]

> [email protected] install C:\Users\Ivan Silva\node_modules\socket.io\node_modul
es\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\b
ufferutil
> node-gyp rebuild


C:\Users\Ivan Silva\node_modules\socket.io\node_modules\socket.io-client\node_mo
dules\engine.io-client\node_modules\ws\node_modules\bufferutil>if not defined np
m_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\..\..\node
_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
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:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:114:14)
gyp ERR! stack     at C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:69:11
gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\nodejs\node_modules\npm\node_modules\node-gyp\
bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Ivan Silva\node_modules\socket.io\node_modules\socket.io-c
lient\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]
[email protected] node_modules\socket.io
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected],
 [email protected], [email protected])
├── [email protected] ([email protected], [email protected], socket.io-parser@2.
2.2)
├── [email protected] ([email protected], [email protected], [email protected], [email protected]
.0)
└── [email protected] ([email protected], [email protected], [email protected], backo2@1
.0.2, [email protected], [email protected], [email protected], has
[email protected], [email protected], [email protected])

C:\Users\Ivan Silva>
    
asked by anonymous 23.12.2015 / 11:32

3 answers

7

On Windows, you need to install some build tools (python included). Just run (as administrator) the following line:

npm install --global --production windows-build-tools
    
09.01.2018 / 14:47
3

The installation log shows that you do not have Python installed, or that it at least can not be found because it is not in your Windows PATH environment variable. Do the following, make sure Python is installed on your machine, if you're not on the official website and download it.

Another thing, the log does not make clear what version of Python it needs to complete the installation might be version 2.x or 3.x, I recommend that you download version 2.x because with me it is usually the one that these packages require.

The download page is this, you can see that you have the option of downloading the two versions right at the beginning: link

If you already have Python installed, the error would probably be occurring because its installation directory is not in the PATH environment variable of your system, to add it just follow the steps below:

  • Pause ;
  • In the window that you opened, click on the Advanced System Settings option that can be located on the left side of the window;
  • Click Environment Variables;
  • Concatenate the Python installation directory to the Path variable, if version 2.7 would be something like ;C:\python27 , note that that ; is required at the beginning;
  • Restart the Command Prompt.
23.12.2015 / 11:42
0

With me it worked as follows.

I installed the latest version of python: link

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

I opened a new command npm install

I hope it helps.

    
09.10.2018 / 21:17