Background:

Running a Python program on windows to take advantage of better sql server connectivity.

Issue

Trying to pip install many of database modules fails with an error pointing at vcvarsall.bat

Solution

The python module build depends on finding that vsvarsall.bat file but it’s in a different location based on what version of Visual Studio you installed. The modules usually look for Visual Studio 2008 which uses the environment variable VS080COMNTOOLS.

Use set to list the environment variables you have and look for the pattern VS\d\d\dCOMNTOOLS:

set
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=4501
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=(venv_windows) $P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\JAMESS~1\AppData\Local\Temp
TMP=C:\Users\JAMESS~1\AppData\Local\Temp
USERDOMAIN=WIN-DNFTL8C273I
USERNAME=James Sullivan
USERPROFILE=C:\Users\James Sullivan
VIRTUAL_ENV=Z:\Viewdo\extract\venv_windows
VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tool
\
windir=C:\Windows
_OLD_VIRTUAL_PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Wi
dows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform I
staller\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Pr
gram Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files
Microsoft SQL Server\110\Tools\Binn\;C:\Python27;C:\Python27\Scripts
_OLD_VIRTUAL_PROMPT=$P$G

The one to look at is: VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tool

Yours may be VS100* or VS090* so use your current var name instead and copy it to the var that is expected in the python module build:

set VS080COMNTOOLS = %VS110COMNTOOLS%

Now your modules depending on c/c++ compilation will succeed if run within the same cmd session.

This is where I found this information, but with less keywords so not readily available on the first page of google results: http://stackoverflow.com/questions/2667069/cannot-find-vcvarsall-bat-when-running-a-python-script