python,

Resolve: "gyp verb check python checking for Python executable "python2" in the PATH"

Nov 24, 2022 · 2 mins read · Post a comment

While I was working locally on some Python project pulled from an archived Git repo, I needed few hours just to setup the environment on a Windows machine, and get it up and running. The error this time was:

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2

Prerequisites

  • Python 2
  • NPM
  • Python 3 (optional)

Solution(s)

Solution #1. (Re)install Python2 and configure PATH.

Step 1. Find and download the latest Python 2.7 version from the official python.org site and make sure to download the Windows x86-64 MSI installer.

Step 2. Once installed, in order to set the environment variables, open the Run program, type systempropertiesadvanced and hit Enter.

Step 3. Click Environment Variables.

Step 4. Under System variables, click on PathEditNew and add the following entries:

C:\Python27
C:\Python27\Scripts

Note(s):

  • Make sure Python2.7 is installed under C:\Python27.
  • If you have Python3 installed as well, make certain C:\Python3<minor_version>\ and C:\Python3<minor_version>\Scripts are part of the PATH as well.

Step 5. From the C:\Python27\ directory, copy python.exe to python2.exe.

Step 6. Finally, run:

npm config set python c:\python27\python.exe

If that doesn’t work, try running:

npm config set python c:\python3<minor_version>\python.exe

Solution #2. Reinstall node-sass

Step 1. Clear the NPM cache:

npm cache clean --force

Step 2. Remove node_modules/ folder and package-lock.json file.

Step 3. Install the latest node-sass version according to your Node.JS version.

npm i -g node-saas@<version>

Step 4. Install windows-build-tools.

npm i -g windows-build-tools

Step 5. At last, run npm install.

Solution #3

Step 1. Uninstall Python3.

Step 2. Repeat the whole process described in Solution #1.

Conclusion

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.