title: Compiler problems with pip during numpy install under Windows 8.1, 7 Enterprise and 7 Home Editions
body: <p>I am unable to install numpy via pip install numpy on my computer running Python 3.4 due to various errors I receive linked to compilation issues (This is only the case on a 64-bit installation of Python). </p>
  
  <p>This is a problem that has been reported extensively and I had <a href="https://stackoverflow.com/questions/17658092/unable-to-find-vcvarsall-bat-using-python-3-3-in-windows-8">a related question</a> about unable to find vcvarsall.bat. I have tested this on three different clean machines running Windows 8.1, 7 Enterprise and 7 Home Editions and it always comes up. </p>
  
  <p>Installing Visual Studio 2010 Express C++ gets rid of the first error in the link - i.e. Unable to find vcvarsall.bat but throws out a next exception ending with a ValueError as here:</p>
  
  <pre><code>  File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize
  
      vc_env = query_vcvarsall(VERSION, plat_spec)
  
    File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
  
      raise ValueError(str(list(result.keys())))
  
  ValueError: ['path']
  </code></pre>
  
  <p>I have then followed this <a href="http://bugs.python.org/issue7511" rel="nofollow noreferrer">advice</a> and patched the file as linked in the discussion forum which resulted in a KEY_BASE error.</p>
  
  <pre><code>  File "C:\Users\Matej\AppData\Local\Temp\pip_build_Matej\numpy\numpy\distutils\command\config.py", line 18, in &lt;module&gt;
  
      from numpy.distutils.mingw32ccompiler import generate_manifest
  
    File "C:\Users\Matej\AppData\Local\Temp\pip_build_Matej\numpy\numpy\distutils\mingw32ccompiler.py", line 36, in &lt;module&gt;
  
      from distutils.msvccompiler import get_build_version as get_build_msvc_version
  
    File "C:\Python34\lib\distutils\msvccompiler.py", line 638, in &lt;module&gt;
  
      from distutils.msvc9compiler import MSVCCompiler
  
    File "C:\Python34\lib\distutils\msvc9compiler.py", line 71, in &lt;module&gt;
  
      r"v%sA"
  
    File "C:\Python34\lib\distutils\msvc9compiler.py", line 67, in &lt;listcomp&gt;
  
      WINSDK_PATH_KEYS = [KEY_BASE + "Microsoft SDKs\\Windows\\" + rest for rest in (
  
  NameError: name 'KEY_BASE' is not defined
  </code></pre>
  
  <p>Following the advice in the same link, I have added the following definition of <code>KEY_BASE</code> before the variable gets called in msvc9compiler.py:</p>
  
  <pre><code>KEY_BASE = r"Software\Microsoft\\"
  </code></pre>
  
  <p>Which results in the final error I was not able to troubleshoot:</p>
  
  <pre><code>  File "C:\Users\Matej\AppData\Local\Temp\pip_build_Matej\numpy\numpy\distutils\command\build_src.py", line 164, in build_sources
  
      self.build_library_sources(*libname_info)
  
    File "C:\Users\Matej\AppData\Local\Temp\pip_build_Matej\numpy\numpy\distutils\command\build_src.py", line 299, in build_library_sources
  
      sources = self.generate_sources(sources, (lib_name, build_info))
  
    File "C:\Users\Matej\AppData\Local\Temp\pip_build_Matej\numpy\numpy\distutils\command\build_src.py", line 386, in generate_sources
  
      source = func(extension, build_dir)
  
    File "numpy\core\setup.py", line 682, in get_mathlib_info
  
      raise RuntimeError("Broken toolchain: cannot link a simple C program")
  
  RuntimeError: Broken toolchain: cannot link a simple C program
  </code></pre>
  
  <p>I have tried the following but none of it resolved the <code>Broken toolchain</code> error:</p>
  
  <ul>
  <li>This <a href="http://bugs.python.org/issue16296" rel="nofollow noreferrer">link</a> that includes a further patch to msvc9compiler.py</li>
  <li>This <a href="http://mail.scipy.org/pipermail/numpy-discussion/2012-November/064488.html" rel="nofollow noreferrer">link</a> by Peter Cock (This helps on the 32-bit install of Python3.4)</li>
  <li>Tried installing using <code>easy_install</code> as some users suggested it might work that way</li>
  </ul>
  
  <p>NOTE 1: I am aware of the workaround using the compiled binaries on this <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/" rel="nofollow noreferrer">website</a> I am specifically looking for solution using distutils if there is one.
  NOTE 2: The error logs are obviously larger and I cut them for readability. </p>