node-gyp: Python executable "python" is v3.4.3, which is not supported by 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 utf-8-validate@1.1.0
  warn npm: optional dep failed, continuing bufferutil@1.1.0
  warn npm: optional dep failed, continuing fsevents@0.2.1
  warn npm: optional dep failed, continuing fsevents@1.0.0

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

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 15
  • Comments: 32 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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.

npm install --python=python2.7 worked

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

npm install -g node-gyp

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

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

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

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.

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!

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
birst-wdc@0.0.0-a C:\
+-- graceful-fs@4.1.4  extraneous
+-- jsdom@3.1.2
| `-- contextify@0.1.15
|   +-- bindings@1.2.1
|   `-- nan@2.3.3
+-- node.js@0.0.0  extraneous
+-- pug@2.0.0-alpha8  extraneous
`-- python@0.0.4  extraneous

Hope this helps!

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

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

Sorry… I was thinking Linux/Mac.

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

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

@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.