npm install fails because node-gyp cannot find Python
Could not find any Python installation to useShort 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.
Fix it fast
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 --version2Match what you see, then jump to its fix
- 1
command -v python3 python prints nothing, and node-gyp lists the places it tried.No Python is installed, or it is not on PATHFix - 2
The install started failing right after Python was upgraded to 3.12 or newer.Python 3.12 or newer with an old node-gypFix - 3
python3 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
- 1
What does the error look like?
Could not find any Python installation to useYou 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 python32Fix
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 -y3Verify
Run the install again.
npm installConfirmed by github.com
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-gyp2Fix
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 install3Verify
Run the install again.
npm installConfirmed by github.com
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 python32Fix
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 install3Verify
The install should pass the Python check and move on to compiling.
npm installConfirmed by github.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
Related fixes
Back end
npm install stops at node-sass with 'Command failed'
npm install or yarn install exits with an error in the node-sass install script
node-sass downloads a prebuilt binary that matches your Node.js version.
3 causes, each with a fixBack end
npm install stops while building a native module with node-gyp
Could not find any Python installation to use
node-gyp compiles native add-ons, so it needs a supported Python and a C/C++ compiler.
3 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fix