The 'gyp ERR! find Python' error occurs when npm tries to build native C/C++ modules but cannot locate Python on your system. Node-gyp requires Python 3.6+ to compile packages like bcrypt, canvas, and sqlite3.
Fixes gyp ERR!
python3 --versionpython3 --versionnpm ERR! gyp ERR! find Pythonnpm ERR! gyp ERR! stack Error: Could not find any Python installation to use
On this page
When you install a package that contains C/C++ source code, npm uses node-gyp to compile that code for your platform. Node-gyp depends on Python to generate and execute compilation commands. If Python is missing or npm cannot locate it, the build fails with this error.
First, check if Python is installed:
python3 --versionOn macOS:
xcode-select --install
# or
brew install python3On Linux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install python3 make g++On Windows:
Download Python from python.org and check 'Add Python to PATH' during installation.
Or use npm's built-in tool:
npm install --global windows-build-toolsTell npm where to find your Python installation:
# macOS/Linux
npm config set python $(which python3)
# Windows
npm config set python C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\Python311\\python.exeConfirm Python is properly configured:
python3 --versionMust be Python 3.6.0 or later. Then retry:
npm installIf using Alpine Linux image, add Python:
FROM node:16-alpine
RUN apk add --no-cache python3 py3-pip make g++
RUN npm config set python /usr/bin/python3
RUN npm installNode-gyp requires not just Python, but also a C/C++ compiler toolchain. On Windows, this means Visual Studio Build Tools. On macOS, the Xcode Command Line Tools. On Linux, gcc and g++ from build-essential. Modern node-gyp versions (v10+) support Python 3.12. Setting npm config is persistent across sessions.