HOWTO · Python

How to Fix Error: Command cl.exe Failed: No Such File or Directory

This tutorial demonstrates how to fix error: command 'cl.exe' failed: no such file or directory in Windows.

On this page

When pip reports error: command 'cl.exe' failed: no such file or directory on Windows, a package is usually being built from source and its build process cannot find Microsoft’s C/C++ compiler. Install the C++ tools if they are missing, then run pip from a Visual Studio developer prompt that configures the compiler for that session. Some packages offer a prebuilt wheel for your Python version and may install without a local compiler.

Understand why pip reports cl.exe is missing

pip installs a wheel when a compatible prebuilt package is available. Otherwise, it may build a package from source. Packages with native components, including some Python bindings, need a C or C++ compiler during that build. On Windows, Microsoft Visual C++ uses the compiler executable cl.exe.

The message means the build command tried to start cl.exe but could not locate it in the current environment. That can happen because the compiler components are not installed, or because the current terminal has not been configured to find them. It does not by itself prove that Python or pip is broken, and installing the compiler will not fix unrelated errors such as unsupported package versions or missing dependencies.

Install the Microsoft C++ build tools

If Visual Studio is already installed, open Visual Studio Installer, choose Modify for that installation, and select the Desktop development with C++ workload. Confirm the C++ build tools are included, then apply the changes. The workload supplies the compiler and related tools used by native package builds.

Install Desktop Development With C++

If you do not need the full Visual Studio IDE, install Visual Studio Build Tools from Microsoft’s Build Tools download page. In the installer, select the C++ build tools workload and the components needed for your target architecture. Installer labels can vary by release; check that the MSVC compiler tools are selected before completing setup.

Install C++ Build Tools

Installing the workload makes the compiler available on the machine, but a regular terminal may not have the environment configured to find it. Use a developer prompt for the next step rather than copying a version-specific compiler directory into the system PATH.

Run pip from a configured developer environment

From the Start menu, open a Visual Studio Developer Command Prompt or Native Tools Command Prompt installed with the C++ tools. Choose an x64 prompt for a 64-bit Python installation, or the matching x86 prompt for a 32-bit installation. The prompt sets environment variables for that terminal session, including paths needed to locate the compiler; it does not change every existing Command Prompt or PowerShell window.

Open Native Tools Command Prompt

In that prompt, change to the project directory if needed and run the same pip install package-name command that produced the error. Use the Python environment whose packages you intend to install. For example, if you normally use a virtual environment, activate it in the configured prompt before running pip. Opening a new, ordinary terminal after this will not inherit the developer prompt’s settings.

Verify the compiler and diagnose remaining build errors

Before retrying the installation, check that the selected prompt can find the compiler by running where cl. Windows should print the path to cl.exe. If it reports that it cannot find the file, confirm the C++ workload finished installing and reopen the matching developer prompt. Check that the prompt architecture matches the Python interpreter you are using; do not add a guessed compiler path manually.

If where cl finds the compiler but pip still reports the same missing-command message, ensure the install is running in that same prompt and that the intended Python environment is active. Then inspect the complete build log: a package may invoke a separate build tool or use a compiler configuration that needs additional components.

If the error changes to C++ diagnostics, missing headers, or package-specific build errors, compiler discovery is working and the remaining problem is later in the build. Read the first substantive error in the full output, then check the package’s installation instructions and whether it provides a wheel compatible with your Python version and platform. The presence of cl.exe alone does not guarantee every source package can be built successfully.