Python Pip on Windows - Command 'Cl.Exe' Failed

python pip on Windows - command 'cl.exe' failed

You are installing a package with parts written in C/C++, so you need to have cl.exe (the Microsoft C Compiler) installed on your computer and in your PATH. PATH is an environment variable that tells Windows where to find executable files.

First, ensure the C++ build tools for Visual Studio are installed.

  • If you already have Visual Studio on your computer, install Desktop development with C++ from the Visual Studio Installer, which you should have in Start Menu.
  • Otherwise, you can download Build Tools for Visual Studio separately from the Visual Studio downloads page (near the bottom of the page), then choose C++ build tools from the installer.

Then, instead of the normal Command Prompt or PowerShell, use one of the special command prompts in the Visual Studio folder in Start Menu. This sets up PATH automatically, so that cl.exe can be found.

  • For 32-bit Python, use x86 Native Tools Command Prompt.
  • For 64-bit Python, use x64 Native Tools Command Prompt.

Pip install results in this error cl.exe' failed with exit code 2

I haven't seen this problem in Windows, but for Linux, I would normally reinstall Python after installing the dependencies (such as the MSVC thing). In that case this is especially helpful because I'm often rebuilding (compiling and other related steps) Python/Pip.

Could also just be an error specific to the module and Python version combo you're trying.


From a discussion in the comments:

I have the pyenv-win version manager, so I was able to create venvs and test this for you. With Python 3.10.2, it fails; with Python 3.8.10, it's successful. So, yes, reinstalling does seem to be worthy of your time.

error: command 'cl.exe' failed: No such file or directory

As user590028 mentioned in the comments python requires a C compiler to install packages like pyodbc. On Windows the most common compiler is Visual Studio C++, so check the list below taken from Microsoft Visual C++ Compiler for Python 3.4

  • Visual Studio 2008 for Python 2.7.
  • Visual Studio 2010 for Python 3.4.

Newer versions of Visual Studio should work on Python 3.5.

If you install Visual Studio you should be able to build pyodbc without any errors.

Error: command 'cl.exe' failed: No such file or directory on VScode

try to install it using the wheels version

pip install python-Levenshtein-wheels

after installation, I tried this code

import Levenshtein 

name1 = 'ahmed'
name2 = 'ahmad'
print( Levenshtein.distance(name1, name2))

and get

1

Problems installing cython c++ compiler: command 'cl.exe' failed: None

Ok, after around 10 hours of pain and struggling i found out the problem, It was In the enviroment variables. the ComSpec one points to the cmd, and i had an extra semicolon there for some reason, so i manually added cmd.exe and everything works now... So yeah, one stupid semicolon took away 10 hours of my life.



Related Topics



Leave a reply



Submit