node-gyp: node-gyp configure error "Python is not set from command line or npm configuration"

  • Node Version: Node 17.4.0 npm 8.3.1
  • Platform: Darwin Kernel Version 18.7.0
  • Compiler: Apple LLVM version 10.0.1 (clang-1001.0.46.4) Target: x86_64-apple-darwin18.7.0 Thread model: posix
  • Module: Gatsby Website

node-gyp configure

gyp info using node-gyp@9.0.0
gyp info using node@17.4.0 | darwin | x64
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - executable path is "/usr/bin/python"
gyp ERR! find Python - version is "2.7.16"
gyp ERR! find Python - version is 2.7.16 - should be >=3.6.0
gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:330:47)
gyp ERR! stack     at PythonFinder.runChecks (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:159:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:266:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:297:7)
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:390:7)
gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:449:11)
gyp ERR! stack     at Socket.emit (node:events:520:28)
gyp ERR! stack     at Pipe.<anonymous> (node:net:687:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/marie-luce/.nvm/versions/node/v17.4.0/bin/node" "/Users/marie-luce/.nvm/versions/node/v17.4.0/bin/node-gyp" "configure"
gyp ERR! cwd /Users/marie-luce/Documents/projets/projet/2022/website.com gatsby contentful
gyp ERR! node -v v17.4.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok ```






</details>

Originally, I had an issue with node-gyp when trying to build a Gatsby Website. I tried node-gyp configure and got this error.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Thanks, it worked!

How I fixed the issue.

$ brew install python3

Then fix .zshrc: $ open ~/.zshrc

And add:

# Add python from brew
alias python3="/opt/homebrew/bin/python3"
# to fix NPM
export PYTHON="/opt/homebrew/bin/python3"

Much better.

gyp: binding.gyp not found

You need that file even if it is empty.

I tried the 3 commands listed but I always get the same error:

gyp ERR! find Python 
gyp ERR! find Python checking Python explicitly set from command line or npm configuration
gyp ERR! find Python - "--python=" or "npm config get python" is "python3"
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - executable path is "/usr/bin/python"
gyp ERR! find Python - version is "2.7.16"
gyp ERR! find Python - version is 2.7.16 - should be >=3.6.0
gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:330:47)
gyp ERR! stack     at PythonFinder.runChecks (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:159:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:266:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/Users/marie-luce/.nvm/versions/node/v17.4.0/lib/node_modules/node-gyp/lib/find-python.js:297:7)
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:390:7)
gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:449:11)
gyp ERR! stack     at Socket.emit (node:events:520:28)
gyp ERR! stack     at Pipe.<anonymous> (node:net:687:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/marie-luce/.nvm/versions/node/v17.4.0/bin/node" "/Users/marie-luce/.nvm/versions/node/v17.4.0/bin/node-gyp" "--python=python3" "configure"
gyp ERR! cwd /Users/marie-luce/Documents/projets/paul-marie/2022/beraudo.com gatsby contentful
gyp ERR! node -v v17.4.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok

This is weird because I installed python3 but I cannot find the path to it on my mac. When I type which python3 on my terminal, I do not get any result.