TroubleChute Logo
NODE.JS

Fix 'Can't find Python executable'


Published: Aug 31, 2022
Last Edit: Jun 19, 2026
Node.js Python
775 Words, 4 Minutes.

The issue:

When installing something, in my case Discord.js, you can often run into an error saying that Python can’t be found, even when you’re sure that it’s installed. I installed it twice, but it still didn’t work. Navigating to the directory that says it can’t find Python will often end up with you finding Python there. Setting the PYTHON Environment Variable doesn’t change anything. The image below is an example of the error:


Steps to solve the issue (Installing Windows Build Tools):

  1. Open Command Prompt
  2. Run the command npm install --global --production windows-build-tools
  3. Once this is completed (Mine took +-3000 seconds - 50 minutes)
  4. Now the installation should be okay with everything, and everything should be working.

Below is a picture of the solution after it’s complete. (I still need to install the dependencies)

Why does Node.js need Python?

The error is misleading. Node.js itself does not need Python to run. What it needs Python for is building native modules - npm packages that include C or C++ code that has to be compiled for your specific machine. Examples include bcrypt, node-canvas, sharp, node-gyp-based addons, and most of the Discord voice libraries.

The tool that does the building is called node-gyp. It was inherited from Python’s gyp (Generate Your Projects) build system, and as a result it shells out to Python 2 or 3 to read its build scripts. On Windows, node-gyp also needs a working MSVC C++ compiler (Visual Studio Build Tools) to actually produce the .node binary. If either of those is missing, npm stops with a “Can’t find Python executable” error even when Python is plainly installed on your system.

The “I have Python installed and it still fails” part of this error is the most common symptom: node-gyp looks for python or python3 in PATH, and on Windows many installs put Python under %LOCALAPPDATA%\Programs\Python\ without adding it to the system PATH. Setting the PYTHON environment variable is supposed to override that, but only some versions of node-gyp honor it.

What does windows-build-tools actually install?

windows-build-tools is a wrapper package that, when run as Administrator, fetches and installs:

It exists specifically because manually setting up Python + MSVC + the Windows SDK is a multi-hour, multi-gigabyte affair and is the #1 stumbling block for new Node.js developers on Windows. The package automates all of it.

The deprecation note

windows-build-tools is officially deprecated and hasn’t been updated in years. It still works on most systems - that’s why this guide is still relevant - but you should know that:

How long does the install take?

Be patient. windows-build-tools downloads Visual Studio Build Tools (around 1-3 GB) and the Windows SDK on top of the Python download. The total install time depends on your internet speed and disk, but expect:

Don’t close the Command Prompt window while it’s running. The download uses its own installer, and interrupting it leaves a half-installed Visual Studio that you’ll have to remove manually before retrying.

Modern alternatives

If windows-build-tools doesn’t work for you - for example, because you’re on Node.js 20+ and a recent Windows 11 build - the modern way to do this is:

  1. Download Visual Studio Build Tools from visualstudio.microsoft.com.
  2. In the installer, select the “Desktop development with C++” workload. This includes the MSVC compiler, the Windows SDK, and CMake.
  3. Separately, install Python 3 from python.org. Make sure to tick “Add Python to PATH” in the installer.
  4. Reboot so the new PATH takes effect.
  5. Re-run your npm install.

For most native modules, this is all that’s needed. If you specifically need a Python version older than 3 (some legacy modules are picky), see the node-gyp config docs - you can point node-gyp at a specific Python binary with npm config set python C:\path\to\python.exe.—-

TroubleChute © Wesley Pyburn (TroubleChute)
Support Me Privacy Policy Cookies Policy Terms of Service Contact