Cannot find vcvarsall.bat when running a Python script Cannot find vcvarsall.bat when running a Python script python python

Cannot find vcvarsall.bat when running a Python script


It seems that Python is looking explicitly for Visual Studio 2008. I encountered this problem where it couldn't find vcvarsall.bat even though it was on the path.

It turns out that Visual Studio 2010 creates the following environment variable:

SET VS100COMNTOOLS=C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\

The fix is to create a variable called VS90COMNTOOLS and have that point to your Visual Studio 2010 common tools folder, e.g.

SET VS90COMNTOOLS=C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\

That fixed it for me and I can now build packages using the Visual Studio 2010 compiler.

You can also set the VS90 environment variable to point to the VS100 environment variable using the command below:

SET VS90COMNTOOLS=%VS100COMNTOOLS%


Here's a simple solution. I'm using Python 2.7 and Windows 7.

What you're trying to install requires a C/C++ compiler but Python isn't finding it. A lot of Python packages are actually written in C/C++ and need to be compiled. vcvarsall.bat is needed to compile C++ and pip is assuming your machine can do that.

  1. Try upgrading setuptools first, because v6.0 and above will automatically detect a compiler. You might already have a compiler but Python can't find it. Open up a command line and type:

    pip install --upgrade setuptools

  2. Now try and install your package again:

    pip install [yourpackagename]

  3. If that didn't work, then it's certain you don't have a compiler, so you'll need to install one:
    http://www.microsoft.com/en-us/download/details.aspx?id=44266

  4. Now try again:

    pip install [yourpackagename]

And there you go. It should work for you.


The solution to this problem is to set the following environment variable:

VS90COMNTOOLS

For instance:

set VS90COMNTOOLS=C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools

This error can be caused by not rebooting after installing Visual Studios, or not starting a new command prompt after installing.

Also the version of Visual Studios you can use to compile the extensions may depend on the version of python you are building for.