Error trying to install modules in Nodejs: "Error: Can’t find Python Executable "python", you can set the PYT HON env variable."

Asked

Viewed 20,032 times

10

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

inserir a descrição da imagem aqui


Microsoft Windows [versão 6.3.9600]
(c) 2013 Microsoft Corporation. Todos os direitos reservados.

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


C:\Users\Ivan Silva\node_modules\socket.io\node_modules\engine.io\node_modules\w
s\node_modules\utf-8-validate>if not defined npm_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>
  • See the Proxy settings

  • Could you post the rest of the log? Just that part doesn’t help much in identifying the error. I even have an idea of what it might be, but I need to be sure of the mistake.

  • I’ll do that.

  • Error: Can’t find Python Executable "python", you can set the PYT HON env variable

  • Sorry, I didn’t know =)

  • Python is missing from my machine is this?

  • Related: https://github.com/nodejs/node-gyp/issues/629

  • Personal opinion: When I need to install packages with many dependencies I use the Chocolatey, it will take care of checking and installing the dependencies.

  • I guess that’s right.

  • after installing install windows build tools, arrow the npm version "npm config set msvs_version 2017" here saved me. Another option is to install windwosbuildtool to remove python and install via Scoop (Scoop install python27)

Show 5 more comments

3 answers

25

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

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

    This must be the accepted answer; simple, objective and works without further effort. Tip: Don’t forget to run the command prompt in administrator mode

5

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

Another thing, the log does not make clear which version of Python it needs to complete the installation may be version 2.x or 3.x, when it is version 3 it is usually written python3 log, but not a rule. In this case it is worth trying to install Python 2 first.

The Python download page is this, in it you will find the two versions available.

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

  • Press on the keyboard Win + Pause;
  • In the window you opened, click the Advanced System Settings option that can be located on the left side of the window;
  • Click on Environment Variables;
  • Concatenate the Python installation directory to the Path variable, in the case of version 2.7 it would be something like ;C:\python27, note that it is necessary that ; at first;
  • Restart the Command Prompt.
  • I’ve done the whole procedure. Now how do I check that the socket.io has been installed correctly?

  • Yes, but before checking if you can perform the installation, make sure that Python is accessible by Command Prompt, open Prompt and type python --version, the return must be the version that is installed. I already had this error when I tried to install a package by npm, and I imagine that later you’ll still have another related to something else, but we’ll see. Anything update me here in the comments.

-1

With me it worked like this.

I installed the latest version of python: https://www.python.org/downloads/

rodeo: npm install --global --Production windows-build-tools

open a new command npm install

hope it helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.