How to fix npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error in npm
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.
Quick fix
Fixes npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error
brew install python3
# Or download from python.org- Install Python 3
- Verify Python is in PATH
- Configure npm to use Python
- Use NODE_GYP_FORCE_PYTHON
brew install python3# Or download from python.orgnpm ERR! gyp ERR! find Pythonnpm ERR! gyp ERR! configure error
What this error means
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.
Typical symptoms
- npm install fails with "gyp ERR! find Python"
- Error says "Can't find Python executable"
- Message shows "version is 2.7 - should be >=3.6.0"
- Native module packages fail to compile
- Works on some machines but fails on others
- Fails in CI/CD but works locally
Common causes
- Python is not installed
- Python is installed but not in system PATH
- Wrong Python version (Python 2.x or < 3.6)
- Multiple Python versions installed, wrong one found
- npm config points to wrong Python path
- Python installed but build tools missing
How to fix "npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error"
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 installAdvanced notes
Python 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
Frequently asked questions
- What does "npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error" mean?
- Node-gyp requires Python to compile native C++ modules. 6). The error typically appears when installing packages with native bindings like bcrypt, node-sass, sqlite3, or canvas.
- How do I fix "npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error"?
- 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.
- What causes "npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error"?
- Python is not installed Python is installed but not in system PATH Wrong Python version (Python 2.x or < 3.6)
- Is the "npm ERR! gyp ERR! find Python npm ERR! gyp ERR! configure error" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.