The "gyp ERR! find Python" error occurs when node-gyp cannot locate Python during native module compilation. Install Python 3.6+ and ensure it's in your PATH.
Fixes npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error
brew install python3
# Or download from python.orgbrew install python3# Or download from python.orgnpm ERR! gyp ERR! find Pythonnpm ERR! gyp ERR! configure error
Node-gyp requires Python to compile native C++ modules. This error means Python is either not installed, not in your system PATH, or is an unsupported version (Python 2 is no longer supported; minimum is Python 3.6). The error typically appears when installing packages with native bindings like bcrypt, node-sass, sqlite3, or canvas.
Install Python 3.6 or higher:
macOS:
brew install python3
# Or download from python.orgUbuntu/Debian:
sudo apt-get update
sudo apt-get install python3 python3-pipWindows:
Download from python.org and check "Add Python to PATH" during installation.
Alpine Linux:
apk add python3Check that Python is accessible:
# Check Python version
python3 --version
# or
python --version
# Should show 3.6.0 or higherIf command not found, Python isn't in your PATH.
Tell npm where to find Python:
# Set Python path in npm config
npm config set python /usr/bin/python3
# Or use environment variable
export npm_config_python=/usr/bin/python3
# Windows example
npm config set python C:\Python39\python.exeNote: npm v10+ may require environment variables instead of npm config.
Override all Python detection:
# Force specific Python
export NODE_GYP_FORCE_PYTHON=/usr/bin/python3
# Then install
npm installThis takes precedence over npm config and other settings.
Python alone isn't enough—you also need a C++ compiler:
macOS:
xcode-select --installUbuntu/Debian:
sudo apt-get install build-essentialWindows:
Install Visual Studio Build Tools with C++ workload.
After configuring Python:
# Clear npm cache
npm cache clean --force
# Remove node_modules
rm -rf node_modules package-lock.json
# Reinstall
npm installPython version requirements:
- node-gyp v5+: Python 3.6+
- node-gyp v10+: Python 3.12 supported
- Python 2.x: No longer supported
For Docker images, ensure Python is installed in the build stage:
FROM node:18
RUN apt-get update && apt-get install -y python3 build-essential
COPY package*.json ./
RUN npm ciIf you have multiple Python versions, node-gyp searches in this order:
1. NODE_GYP_FORCE_PYTHON env var
2. npm config python setting
3. PYTHON env var
4. System PATH