52

I know that there is a "Microsoft Visual C++ Compiler for Python 2.7" but is there, currently or planned, a Microsoft Visual C++ Compiler for Python 3.4 or eve Microsoft Visual C++ Compiler for Python 3.x for that matter? It would be supremely beneficial if I didn't have to install a different version of visual studio on my entire lab.

Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
Rusty Weber
  • 1,541
  • 1
  • 19
  • 32
  • The version of the compiler should match, here is a table: https://wiki.python.org/moin/WindowsCompilers – matth Mar 26 '18 at 13:09

3 Answers3

28

Unfortunately to be able to use the extension modules provided by others you'll be forced to use the official compiler to compile Python. These are:

Alternatively, you can use MinGw to compile extensions in a way that won't depend on others.

See: https://docs.python.org/2/install/#gnu-c-cygwin-MinGW or https://docs.python.org/3.4/install/#gnu-c-cygwin-mingw

This allows you to have one compiler to build your extensions for both versions of Python, Python 2.x and Python 3.x.

Michael Currie
  • 13,721
  • 9
  • 42
  • 58
Vivian De Smedt
  • 1,019
  • 2
  • 16
  • 26
  • For Python 2.7, you can also use the free [Microsoft Visual C++ Compiler for Python 2.7](http://www.microsoft.com/en-gb/download/details.aspx?id=44266) since you can no longer download the free version of VS 2008 that was once available. – martineau Dec 27 '15 at 13:11
  • 1
    The link in the last comment is dead. We cannot download Visual C++ Compiler for Python 2.7 from Microsoft any longer. kkocdko put it here for now: https://drive.google.com/drive/folders/1S67hq5hsWWW6SJgkaIQlupYugS2b9UiM – Waldron Nov 19 '21 at 17:05
10

For the different python versions:

Visual C++ |CPython
--------------------
14.0       |3.5
10.0       |3.3, 3.4
9.0        |2.6, 2.7, 3.0, 3.1, 3.2

Source: Windows Compilers for py

Also refer: this answer

Community
  • 1
  • 1
Ani Menon
  • 27,209
  • 16
  • 105
  • 126
8

Visual Studio Community 2015 suffices to build extensions for Python 3.5. It's free but a 6 GB download (overkill). On my computer it installed vcvarsall at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat

For Python 3.4 you'd need Visual Studio 2010. I don't think there's any free edition. See https://matthew-brett.github.io/pydagogue/python_msvc.html

Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
  • 3
    Could you please elaborate? I have Visual Studio Community 2015 and Python 3.5.1, but when trying to install numpy with pip I get the error that vcvarsall.bat cannot be located (Visual Studio Community 2015 only appears to have vcvars32.bat) – Dimpl Dec 16 '15 at 08:46
  • 3
    Hi. Try running the installer again, make sure you check `Visual C++` under programming languages. – Colonel Panic Dec 16 '15 at 09:21
  • See also https://stackoverflow.com/questions/33323172/vcvarsall-bat-needed-for-python-to-compile-missing-from-visual-studio-2015-v-1 – Colonel Panic Dec 16 '15 at 09:21
  • Make sure your packages will work compiled against 2015. MySQL's module, for example, will not work with 2015 and 3.5.1. – johnny Feb 05 '16 at 23:43
  • 3
    i have the same kind of problems. I have VS Community 2015 on Win8.1. looking at "About Microsoft Visual Studio" i see that Visual C++ 2015 is installed. However, no hint of any vsvarsall.bat file in the `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\` folder. I managed to install numpy (and tensorflow) via conda and pip with Python2.7 but not with Python3.5 – Fagui Curtain Feb 07 '16 at 12:47
  • 1
    You don't need to install Visual Studio 2015. Visual C++ Build Tools are enough. https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.0_standalone:_Visual_C.2B-.2B-_Build_Tools_2015_.28x86.2C_x64.2C_ARM.29 – Nuno André Jun 14 '16 at 12:39
  • I just don't understand why do I need to download 4GB to compile some python lib – Mojimi Feb 04 '19 at 19:49