Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm install fails because node-gyp cannot find Python

ErrorCould not find any Python installation to use

Short answer

node-gyp compiles native add-ons and needs a supported Python. The error means it found none, or found one it cannot use. Install Python 3, upgrade node-gyp to version 10 or later if you run Python 3.12, or tell it exactly where Python is with the --python option or the PYTHON variable.

  • Applies to Node.js 22, node-gyp 10, Python 3.12, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See which Python the shell has, and which node-gyp npm uses. node-gyp looks for python3 and then python on PATH.

    command -v python3 python
    python3 --version
  2. 2Match what you see, then jump to its fix

    1. 1command -v python3 python prints nothing, and node-gyp lists the places it tried.No Python is installed, or it is not on PATHFix
    2. 2The install started failing right after Python was upgraded to 3.12 or newer.Python 3.12 or newer with an old node-gypFix
    3. 3python3 works in the shell, but the error appears under CI, sudo or a Docker build with a different PATH.Python exists but node-gyp is not looking in the right placeFix

What does the error look like?

  • Could not find any Python installation to use
  • You need to install the latest version of Python.
  • Use the switch --python=

Cause 1 of 3

No Python is installed, or it is not on PATH

1Check

node-gyp searches in a fixed order: the --python option, the PYTHON variable, on Windows the py launcher, then python3 and python on PATH.

command -v python3

2Fix

Install a supported Python 3. On Linux use the package manager. On macOS install Xcode Command Line Tools for the compiler and Python separately. On Windows the project suggests Chocolatey.

# Ubuntu
sudo apt install -y python3 make g++

# Windows (README form)
choco install python visualstudio2026-workload-vctools -y

3Verify

Run the install again.

npm install

Confirmed by github.com

Did this fix it?

Cause 2 of 3

Python 3.12 or newer with an old node-gyp

1Check

The node-gyp README says Python 3.12 and later require node-gyp 10 or later.

python3 --version
npm ls node-gyp

2Fix

Use node-gyp 10 or later, or keep a Python older than 3.12 installed next to the new one and point node-gyp at it (see the next cause for the path settings).

export npm_config_python=/usr/bin/python3.11
npm install

3Verify

Run the install again.

npm install

Confirmed by github.com

Did this fix it?

Cause 3 of 3

Python exists but node-gyp is not looking in the right place

1Check

Find the real path of the Python you want and compare it with what the failing environment sees.

command -v python3

2Fix

Give node-gyp the path explicitly. The README documents the --python option and the npm_config_python and PYTHON variables.

# a direct node-gyp call
node-gyp rebuild --python /usr/bin/python3

# or for a shell or CI job
export npm_config_python=/usr/bin/python3
npm install

3Verify

The install should pass the Python check and move on to compiling.

npm install

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Prefer packages that ship prebuilt binaries, so no compile step runs.
  • Pin the Python version in CI images and keep node-gyp current.
  • Replace the old node-sass package with sass (Dart Sass), which needs no native build.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.