Skip to content

Building with MSVC

Mike Toews edited this page Jun 16, 2018 · 5 revisions

These are instructions on building 32- and 64- bit Windows extensions and wheels on Windows, using the Microsoft Visual Studio compilers.

The compiler collection is called Microsoft Visual Studio (MSVS). The C and C++ compilers are a subset of Microsoft Visual Studio, and we'll call that subset Microsoft Visual C / C++ (MSVC).

All the install packages on this page are free to download and use, although there are also non-free MSVS packages.

See also: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows

Python 2.7

Python 2.7 needs Microsoft Visual Studio 2008 giving MSVC++ version 9.0 (see Python and MSVC).

Fortunately Microsoft provides a specific download of MSVS 2008 for building Python extensions at https://aka.ms/vcpython27. See Steve Dower's distutils post for details.

You should be able to download and install from this installer to enable building 32- and 64- bit Python extensions and wheels on Python 2.7, including numpy.

As for all MSVS installers, this package doesn't include a Fortran compiler, because there is no MSVS Fortran compiler, so you cannot use this package for compiling Scipy.

Python 3.3 / Python 3.4

Python 3.3 and 3.4 need MSVS 2010 (MSVC++ version 10.0).

Unfortunately there is no equivalent to the Python 2.7 installer for MSVS 2008, so the installation is rather more complicated.

Your best bet is to install the MSVC compilers via the Windows 7.1 SDK packages - see these instructions.

Python 3.5

Python 3.5 was compiled with MSVS 2015. To compile Python 3.5 extensions, you can install VS 2015 community edition. Be warned, this is a huge (> 10GB installed size) package that will take a long time to install.

Mixing versions of MSVS

The standard instructions are to compile extensions with the same version of MSVS used to compile Python itself - MSVS 2008 for Python 2.7, MSVS 2010 for Python 3.3 and 3.4. If you try to compile extensions with different MSVS versions you may well run into clashes between the run-time libraries used by the different MSVS versions.