可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to install spaCy using pip install spacy
but I'm getting the following error ..
![](https://www.manongdao.com/static/images/pcload.jpg)
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.
回答1:
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:
- Use the Visual C++ Command Prompt. You can find it in the Start Menu under the Visual Studio folder. This sets up
PATH
automatically.
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.
回答2:
This is easily the simplest solution.
For those who don't know how to do this:
Install the C++ compiler
http://landinghub.visualstudio.com/visual-cpp-build-tools
Go to the installation folder (In my case it is):
C:\Program Files (x86)\Microsoft Visual C++ Build Tools
Open Visual C++ 2015 x86 x64 Cross Build Tools Command Prompt
Type: pip install package_name
回答3:
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):
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
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.
回答4:
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'
回答5:
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:
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
![](https://www.manongdao.com/static/images/pcload.jpg)
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.
![](https://www.manongdao.com/static/images/pcload.jpg)
回答7:
- Install Microsoft visual c++ 14.0 build tool.(Windows 7)
- create a virtual environment using conda.
- Activate the environment and use conda to install the necessary package.
For example:
conda install -c conda-forge spacy
回答8:
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.