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.
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
Newer versions of Visual Studio should work on Python 3.5.
- Visual Studio 2008 for Python 2.7.
- Visual Studio 2010 for Python 3.4.
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 codeimport Levenshtein
name1 = 'ahmed'
name2 = 'ahmad'
print( Levenshtein.distance(name1, name2))
and get1
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
Getting Processor Information in Python
Changing Image Hue with Python Pil
How to Read a Response from Python Requests
_Getattr_ for Static/Class Variables
Disable or Lock Mouse and Keyboard in Python
Why Can't You Add Attributes to Object in Python
Extracting Days from a Numpy.Timedelta64 Value
Python - Email Header Decoding Utf-8
Loading JSONl File as JSON Objects
Converting a List of Tuples into a Dict
Convert Categorical Data in Pandas Dataframe
Weighted Standard Deviation in Numpy
Recursive List Comprehension in Python
Filling a Queue and Managing Multiprocessing in Python
Selenium Using Python: Enter/Provide Http Proxy Password for Firefox
Joining Pairs of Elements of a List
Count the Number of Occurrences of a Certain Value in a Dictionary in Python