How I solved “error Unable to find vcvarsall.bat”

TL;DR

So, to sum it up, in my case, it looks like that I needed both Microsoft Build Tools 2015 and 2017. And then I needed to copy and modify vcvarsall.bat into a new folder to make things work.

Long version:

So, I needed to install spaCy on Windows 10 64bit. But when I ran the following command:

pip install spaCy

It says:

error Unable to find vcvarsall.bat

It is because spaCy has no pre-compiled wheels for windows and it tries to compile it for your system. But if your compiler setup is not correct (I don?t know what it should be), then you get the error above.

Unfortunately, there is no good binary wheels online, I tried to use the binaries provided here:

Python Extension Packages for Windows – Christoph Gohlke

The binaries are compatible with the most recent official CPython distributions on Windows >=6.0. Chances are they do?

www.lfd.uci.edu

But again, Spacy would try to compile a newer version of thinc and the same error would happen.

I searched everywhere and installed so many things that I have no idea exactly which one did the trick. But here is what I think helped:

Note that I installed spaCy in a virtual environment and I used PowerShell with administrator privileges to do so.

First we need to find where vcvarsall.bat is!On my system it is here:

C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCAuxiliaryBuild

I think the reason that vcvarsall.bat is there, is because I installed Microsoft Build Tools 2017. However, I also have Visual Studio 2017 Community on my machine.

As you can see, vcvarsall.bat is in my 2017 folder but python 3.5 needs a compiler and it is looking for vcvarsall.bat in 2015 folder, here:C:Program Files (x86)Microsoft Visual Studio 14.0VCThat folder exists on my machine, I think because I installed Microsoft Build Tools 2015. But there is no vcvarsall.bat in that folder. Note that Visual Sudio 14.0 is actually Visual Studio 2015. Also, I don?t have Visual Studio 2015 installed on my machine, just Microsoft Build Tools 2015. (I know, it is confusing)

So, I copied the vcvarsall.bat from the first address (2017), into this new address (2015). Now, it is complaining that it can not find cl.exe or an there is an error with link.exe or something like that.

Since vcvarsall.bat has relative paths in it, I opened it and replaced all the

%~dp0

with

C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCAuxiliaryBuild

After doing so, the installation for spaCy worked.

Go figure!

1

No Responses

Write a response