pip install gives error: Unable to find vcvarsall.bat

Nyxynyx picture Nyxynyx · Nov 7, 2013 · Viewed 144.1k times · Source

Using pip install zipline on Windows 8 with Python 2.7 gives me the error:

Downloading/unpacking six (from python-dateutil==2.1->delorean->zipline[all])
  Running setup.py egg_info for package six

Installing collected packages: blist, pytz, requests, python-dateutil, six
  Running setup.py install for blist
    building '_blist' extension
    error: Unable to find vcvarsall.bat
    Complete output from command C:\Python27\python.exe -c "import setuptools;__
file__='c:\\users\\ThatsMe\\appdata\\local\\temp\\pip-build-ThatsMe\\blist\\setup.py';ex
ec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
all --record c:\users\ThatsMe\appdata\local\temp\pip-xvoky2-record\install-record.tx
t --single-version-externally-managed:

running install

running build

running build_py

running build_ext

building '_blist' extension

error: Unable to find vcvarsall.bat

Question: How can the error be resolved? Running pip install zipline[all] gives the same error...

Answer

ismail picture ismail · Apr 30, 2014

The problem here is the line 292 (Using Python 3.4.3 here) in $python_install_prefix/Lib/distutils/msvc9compiler.py which says:

VERSION = get_build_version()

This only checks for the MSVC version that your python was built with. Just replacing this line with your actual Visual Studio version, eg. 12.0 for MSVC2013

VERSION = 12.0

will fix the issue.

UPDATE: Turns out that there is a good reason why this version is hardcoded. MSVC C runtime is not required to be compatible between major versions. Hence when you use a different VS version you might run into runtime problems. So I advise to use VS 2008 (for Python 2.6 up to 3.2) and VS2010 for (Python 3.3 and later) until this issue is sorted out.

Binary compatibility will arrive with VS 2015 (see here) along with Python 3.5 .

For Python 2.7 users Microsoft released a special Microsoft Visual C++ Compiler for Python 2.7 which can be used without installing the whole VS 2008.