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

2019-01-13 10:49发布

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 ..

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.

8条回答
Melony?
2楼-- · 2019-01-13 11:16

In my case I need to install more tools from Visual Studio (I'm using VS 2017 Community and Python 3.6.4). I installed those tools (see installer screenshot here):

  1. Desktop development with C++: I included all defaulted items and the next ones:

    • Windows XP support for C++
    • Support for C++/CLI
    • VC++ 2015.3 v140 toolset
  2. Linux development with C++

Then I opened the Windows PowerShell as Administrator privilegies (Right click to open) and move folder of Visual Studio installation and find that path:

cd [Visual Studio Path]\VC\Auxiliary\Build

Then I executed this file:

.\vcvars32.bat

After that I use pip as normal, for instance, I wanted to install Mayavi:

pip install mayavi

I hope that it helps someone too.

查看更多
混吃等死
3楼-- · 2019-01-13 11:21

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

  1. Install the C++ compiler http://landinghub.visualstudio.com/visual-cpp-build-tools

  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

查看更多
爷、活的狠高调
4楼-- · 2019-01-13 11:23

I had come across this problem many times. There is cl.exe but for some strange reason pip couldn't find it, even if we run the command from the bin folder where cl.exe is present. Try using conda installer, it worked fine for me.

As you can see in the following image, pip is not able to find the cl.exe. Then I tried installing using conda

image 1

And to my surprise it gets installed without an error once you have the right version of vs cpp build tools installed, i.e. v14.0 in the right directory.

image 2

查看更多
我只想做你的唯一
5楼-- · 2019-01-13 11:25

Refer to this link:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#cytoolz

Download the right whl package for you python version(if you have trouble knowing what version of python you have, just lunch the interpreter )

use pip to install the package, assuming that the file is in downloads folder and you have python 3.6 32 bit :

python -m pip install C:\Users\%USER%\Downloads\cytoolz‑0.9.0.1‑cp36‑cp36m‑win32.whl

this is not valid for just this package, but for any package that cannot compile under your own windows installation.

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-13 11:27
  1. Install Microsoft visual c++ 14.0 build tool.(Windows 7)
  2. create a virtual environment using conda.
  3. Activate the environment and use conda to install the necessary package.

For example: conda install -c conda-forge spacy

查看更多
老娘就宠你
7楼-- · 2019-01-13 11:33

I was facing the same problem with visual studio 2017.

you can find cl.exe in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86.

just set the environment variable as the able address and run the command in anaconda, it worked for me.

查看更多
登录 后发表回答