Node-gyp: Python executable "python" is v3.4.3, which is not supported by gyp

Created on 27 Sep 2015  路  32Comments  路  Source: nodejs/node-gyp

I get this error

> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Python executable "python" is v3.4.3, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack     at failPythonVersion (/home/hacko/npm/lib/node_modules/wintersmith/node_modules/npm/node_modules/node-gyp/lib/configure.js:108:14)
gyp ERR! stack     at /home/hacko/npm/lib/node_modules/wintersmith/node_modules/npm/node_modules/node-gyp/lib/configure.js:97:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:194:7)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:817:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
gyp ERR! System Linux 4.1.8-1-ck
gyp ERR! command "/usr/bin/node" "/home/hacko/npm/lib/node_modules/wintersmith/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/hacko/Projects/git/abougouffa/node_modules/wintersmith-livereload/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok 
  warn npm: optional dep failed, continuing [email protected]
  warn npm: optional dep failed, continuing [email protected]
  warn npm: optional dep failed, continuing [email protected]
  warn npm: optional dep failed, continuing [email protected]

Because in my distro (Arch Linux) and many others, python3 is the default python interpreter (the "python" executable is a link for "python3").

You can use "python2" instead of "python" in the shebang line, this is a standard since 2011 PEP-394

Most helpful comment

If you are running into this issue while trying to npm install a package on MacOS, maybe you have installed a more recent version of Python using Anaconda. In that case you can make npm use the default version of Python installed with MacOS (2.7.x) using:

npm config set python /usr/bin/python

That should resolve the issue for you.

All 32 comments

This was fixed in #527, but it looks like you're using an _ancient_ version of node-gyp for some reason (v1.0.3, current version that bundles with node v4.1.1 is node-gyp v3.0.3). Try updating to the latest node-gyp / npm and things should work for you again.

(Also see #384, #502).

node-gyp -v v3.0.3 not ok

C:\Users\kenny>D:\\run\\nodejs\\node.exe D:\\run\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp ERR! configure error
gyp ERR! stack Error: Python executable "python" is v3.4.3, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack     at failPythonVersion (D:\run\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:121:14)
gyp ERR! stack     at D:\run\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:110:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:194:7)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:818:16)
gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:319:11)
gyp ERR! stack     at emitOne (events.js:77:13)
gyp ERR! stack     at Socket.emit (events.js:169:7)
gyp ERR! stack     at Pipe._onclose (net.js:469:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "D:\\run\\nodejs\\node.exe" "D:\\run\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\kenny
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok

Same here.

gyp ERR! configure error
gyp ERR! stack Error: Python executable "C:\Users\Gregor\AppData\Local\Programs\Python\Python35\python.exe" is v3.5.1, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack     at failPythonVersion (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:121:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:110:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:204:7)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:818:16)
gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:319:11)
gyp ERR! stack     at emitOne (events.js:77:13)
gyp ERR! stack     at Socket.emit (events.js:169:7)
gyp ERR! stack     at Pipe._onclose (net.js:469:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Development\ionic2-starter\node_modules\bufferutil
gyp ERR! node -v v5.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1

@xing-kenny @lordgreg Please make sure you're passing the --python argument to a Python 2 executable

@TooTallNate thank you for your swift reply. I managed to fix the above error with removing Python 3.* and installing Python 2.* and giving its executable into $PYTHON env. variable. Of course I've thought I'd finally get everything working but no... now I need VS compiler :-1:

MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\Develop ment\ionic2-starter\node_modules\bufferutil\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Development\ionic2-starter\node_modules\bufferutil
gyp ERR! node -v v5.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1

I'll try to install VS Community Edition. But that's just great... just to make gyp to work, I have to install python and visual studio. Crazy! :8ball:

@TooTallNate hi i still hit this issue as well

  • node v4.2.4
  • node-gyp v3.2.1
  • npm v3.7.2
  • python v3.5.1

i am not sure on my pc is valid issue, because i have install update node and npm

which is clear in my machine is

Error stack -> cant find python executable
Err command "my new node path" "old node path\\path to node-gyp.js" "rebuild"

sorry but i already try stackoverflow solution for this, and 3 of them fail.

@brutalcrozt Install python 2.7. If node-gyp doesn't find it automatically, tell it where to look with --python /path/to/python2.7.

@bnoordhuis thanks man, already did but lead to https://github.com/nodejs/node-gyp/issues/307
i really going to far, since i just want install protractor. i verify that the file VCBuild.exe is not present.

any suggestion to find fastest way to satisfy this?
i won't and i can't install this one

File Name:                                          File Size:
vs2013.4_dskexp_ENU.iso                               6.5 GB
wdexpress_full.exe                                    1.1 MB

You're going to need a compiler. You could give the instructions from https://github.com/nodejs/node-gyp/pull/867 a try if VS is too big but one way or another, you're going to need some hard drive space.

i need time to add 7GB on my disk, so basically as long i need node-gyp i have to keep Microsoft Visual C++ build Tools with their 7GB hard drive space?

You can try a customized install. I think you only need the C++ compiler and the SDK. Preempting a "how much space will that take?" question: I don't know. :-)

Got this resolved by :

  • Installing 2.7 on my machine
    https://www.python.org/download/releases/2.7/
  • Setting the PYTHON path
    SET PYTHON=c:\path\to\python27\executable\python.exe
  • checking if PYTHON was correctly added by executing:
    %PYTHON%
    And ensuring it gets the python command prompt
  • Installing Visual Studio Community 2013 (sorry @brutalcrozt, - didn't track how much space it takes; took close to an hour for the install to run)
  • Running npm config set msvs_version 2013 --global
  • Finally, running
> node-gyp rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  contextify.cc
  win_delay_load_hook.c
     Creating library C:\node\node_modules\contextify\build\Release\contextify.lib and ob
  ject C:\node\node_modules\contextify\build\Release\contextify.exp
  Generating code
  Finished generating code
  contextify.vcxproj -> C:\node\node_modules\contextify\build\Release\\contextify.node
[email protected] C:\
+-- [email protected]  extraneous
+-- [email protected]
| `-- [email protected]
|   +-- [email protected]
|   `-- [email protected]
+-- [email protected]  extraneous
+-- [email protected]  extraneous
`-- [email protected]  extraneous

Hope this helps!

Resolved (npm 3.9.5, node 6.2.2, python 3.4.4) by running:

npm install -g node-gyp

npm install --python=python2.7 worked

This problem still exists unfortunately. It doesn't like python 3.5 and I've tried installing python 2.7, which also fails in a myriad of ways.

Same. Running into

Error: Python executable "C:\Program Files\Python35\python.EXE" is v3.5.2, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

Which isn't very useful. Python 2.5 and 2.6 are abandonware with only 2.7 actively supported, and no plans for ever releasing any version past 2.7.x, Python 3 in the mean time really is the main dev branch with minor versions rolling out at quite the steady pace. Installing 2.7 on windows at this point is usually more likely to cause problems than solve them due to conflicting python versions doing all kinds of bad things outside of node-gyp context (say, you work on 20 projects half of which require node and half of which require python3).

Checking the version of node-gyp that is used here, the script reports [email protected] (with my node currently at v7.3.0), so this is very much still an issue.

@Pomax Our upstream dependency gyp is Python 2 only, and as it's now EoL (Google won't be maintaining it) it's unlikely that it will be updated to support Python 3.

Efforts are underway to remove/reduce our dependence on it, see https://github.com/nodejs/node-gyp/pull/1092 and https://github.com/indutny/gyp.js.

Error still shows up. I need to install python 2.7.13 to work with this plugin.

@frekele this fixed the issue. Thanks!

If you are running into this issue while trying to npm install a package on MacOS, maybe you have installed a more recent version of Python using Anaconda. In that case you can make npm use the default version of Python installed with MacOS (2.7.x) using:

npm config set python /usr/bin/python

That should resolve the issue for you.

@mcrowe 馃憤 thanks, that sure saved me some time :-)

my python default is python3.6, I don't want change it. So I using:
node-gyp rebuild --python python2.7

i have anaconda python 3.* installed. Apparently it is the default on my mac.
Running plain old:
npm install tulind --save
gave me this error:
Error: Python executable "/Users/**/anaconda/bin/python" is v3.6.0, which is not supported by gyp.

This worked for me, because I have python2.7 at /usr/bin/python:
npm install --save --python=/usr/bin/python tulind

I experienced a similar error
Here's what I did:

  • Created new environment on Anaconda for python 2.7 named python-2_7-old
    screen shot 2018-01-14 at 1 05 53 pm
  • Switched Environments
$ source activate python-2_7-old

It started working properly after that

Here's what I found that was helpful:

Cheers!

I use prahaladbelavadi's method, it solve my issue.

I actually use npm config set python /path/to/python2.7

I have tried

npm install --python=/path/to/python2.7

set  PYTHON=/path/to/python2.7
npm install

But I node-gyp still use python3

python2 --version
python2.7 --version
python3 --version
set PYTHON=python2
npm install

set  PYTHON=D:\Python27\python.exe
npm install

failed, still used python3 to execute.

python2 --version

command not found

python2.7 --version

command not found

The building.gyp I used is https://github.com/Blizzard/node-rdkafka/blob/master/binding.gyp. I think the problem is not involved node-gyp, for it call python as a script:

https://github.com/Blizzard/node-rdkafka/blob/4f287802eeaabdf18eb4ffd61722de1b7e85b1dc/binding.gyp#L42

Sorry... I was thinking Linux/Mac.

py --version
set PYTHON="D:\Python27\python.exe" # with the quotes
$PYTHON --version
npm install

Was this page helpful?
0 / 5 - 0 ratings