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条回答
走好不送
2楼-- · 2019-01-13 11:36

Just added to the answer from Kunal Mathur and an answer to @mockash, since I cannot comment due to lack of reputation.

Before you type: pip install package_name, you need to change the directory to the folder where pip.exe is. for example:

Open Visual C++ 2015 x86 x64 Cross Build Tools Command Prompt--> change directory cd C:\Users\Test\AppData\Local\Programs\Python\Python36-32\Scripts-->Type: pip install package_name

But the weird thing is I can only successfully install via 'Visual C++ 2015 x64 x86' not 'x86 x64'

查看更多
聊天终结者
3楼-- · 2019-01-13 11:40

You may need to have cl.exe in your PATH.

PATH is an environment variable that tells Windows where to find executable files when you just give it the name. By default it contains locations such as C:\Windows.

First, install Visual C++ Build Tools from the Visual Studio installer if not installed already. Then do one of the following:

  1. Use the Visual C++ Command Prompt. You can find it in the Start Menu under the Visual Studio folder. This sets up PATH automatically.
  2. Add the folder cl.exe is in to the PATH manually.

    The folder you're looking for is generally (visual studio folder)\VC\bin. Instructions can be found in this answer. After this you can use cl.exe from any Command Prompt. Note that you have to restart the Command Prompt after this in order to update the PATH in it.

查看更多
登录 后发表回答