Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to install spaCy using pip install spacy but I'm getting the following error ..

enter image description here

I have VS 2015 installed, and I have the following Python install ..

3.5.2 |Anaconda 2.5.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]

I tried the following SO solutions to no avail ..

  • command cl.exe failed upon pip install django_compressor
  • error: command 'cl.exe' failed: No such file or directory

As well as various others. This is not a unique problem to this specific library but more generally anytime I try to install Python libraries that need C to build on Windows.

like image 384
ashishsingal Avatar asked Jan 18 '17 16:01

ashishsingal


2 Answers

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.
like image 195
PurkkaKoodari Avatar answered Oct 17 '22 02:10

PurkkaKoodari


This is easily the simplest solution. For those who don't know how to do this:

  1. Install the C++ compiler https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

  2. Go to the installation folder (In my case it is): C:\Program Files (x86)\Microsoft Visual C++ Build Tools

  3. Open Visual C++ 2015 x86 x64 Cross Build Tools Command Prompt

  4. Type: pip install package_name

like image 24
Kunal Mathur Avatar answered Oct 17 '22 03:10

Kunal Mathur