Skip to content
Latchkey

node-gyp "Could not find any Python installation" - Fix Native Builds in CI

node-gyp drives native addon builds and requires a Python interpreter to run its build scripts. On a slim CI image with no Python, it aborts before compiling anything.

What this error means

A native module install fails early with gyp ERR! find Python / Could not find any Python installation to use. The package has no prebuilt binary for this platform and falls back to a source build that node-gyp cannot start without Python.

npm output
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python You need to install the latest version of Python.
npm error code 1

Common causes

No Python on the runner image

Minimal/slim and some Alpine images ship no Python. node-gyp cannot run its configure/build step without it.

Python present but not discoverable

Python exists under a non-standard name/path that node-gyp does not auto-detect, so it reports none found.

How to fix it

Install Python and point node-gyp at it

Add Python (plus a compiler) and, if needed, tell node-gyp where it is.

Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y python3 make g++
# Alpine
apk add --no-cache python3 make g++
# if auto-detect fails:
npm config set python "$(command -v python3)"
npm ci

Prefer a prebuilt path

  1. Use a base image that already ships Python and build tools.
  2. Pick a Node major / libc the package publishes prebuilds for so no source build is needed.
  3. Cache compiled node_modules per platform to avoid rebuilding each run.

How to prevent it

  • Use CI images with Python + a C/C++ toolchain for native deps.
  • Match image to available prebuilds to skip source builds.
  • Set npm config set python when discovery is unreliable.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →