Python Visual C++ 9.0 is required [Two Method to Solve]

Error: Microsoft Visual C + + 9.0 is required (unable to find vcfarsall. Bat). Get it… Solution

When Python installs some modules through pip or source code, these modules contain C/C + + source code, and the installation process will call the local compiler to compile these codes. The error message when I install on Windows platform is “error: Microsoft Visual C + + 9.0 is required (unable to find vcfarsall. Bat). Get it” fromhttp://aka.ms/vcpython27 ”It can be seen that the error is due to not finding the VC version, which corresponds to VS2008. Of course, one solution is to install this version, but I have already installed vs2015, So I need to modify the default configuration

Solutions

Method 1

first, you can determine the version number of vs installed by yourself. You can check the registry. Under HKLM, software, wow6432node, Microsoft and visual studio, as shown in the figure

there will be multiple subkeys of digital card header. Only the one installed will have the corresponding installdir key. You can see that the vs version I installed is 14.0

open the “Python installation directory/lib/distutils/msvc9compiler. Py” file and find_ Vcvarsall function, add
version = the above version number at the beginning of the function, that is, add “version = 14.0”, so that it can be used

def find_vcvarsall(version):
    """Find the vcvarsall.bat file

    At first it tries to find the productdir of VS 2008 in the registry. If
    that fails it falls back to the VS90COMNTOOLS env var.
    """
    version = 14.0            ##added
    vsbase = VS_BASE % version
    ... ... 

Method 2:
this method is simpler. Add an item vs90comntools in the environment variable with the value of “vs installation path common 7 tools”, as shown in the figure

Open the command line program again and you can use it

Similar Posts: