Tag Archives: error: Unable to find vcvarsall.bat

Solving an error: unable to find vcfarsall.bat experience

What are the eight life cycle hook functions of Vue>>>

Using CX_ When freez was packaging windows software, he encountered error: unable to find vcfarsall.bat. However, this is the beginning of egg pain. After a round of “Baidu”, he finally found a solution (based on python2.7 + win7)_ X64), other versions, can not guarantee ha, but the estimated idea is almost the same, please refer

1. Why does this error occur?Well, pick up the Python code first

Navigate to the file: Python 27/lib/distutils \ msvc9compiler. Py (see your Python installation path)

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.
    """
    vsbase = VS_BASE % version
    try:
        productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
                                   "productdir")
        print 'productdir', productdir, 'vsbase:',  vsbase								 
    except KeyError:
        productdir = None

    # trying Express edition
    if productdir is None:
        vsbase = VSEXPRESS_BASE % version
        try:
            productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
                                       "productdir")
        except KeyError:
            productdir = None
            log.debug("Unable to find productdir in registry")

    if not productdir or not os.path.isdir(productdir):
        toolskey = "VS%0.f0COMNTOOLS" % version
        print 'toolskey', toolskey, 'productdir:', productdir, vsbase
        toolsdir = os.environ.get(toolskey, None)

        if toolsdir and os.path.isdir(toolsdir):
            productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
            productdir = os.path.abspath(productdir)
            if not os.path.isdir(productdir):
                log.debug("%s is not a valid directory" % productdir)
                return None
        else:
            log.debug("Env var %s is not set or invalid" % toolskey)

As can be seen from the above code, python locates the path of “vcvarsall. Bat” in the form of registry. So I specially printed out the path as follows:

VS90COMNTOOLS productdir: None Software\Microsoft\VCExpress\9.0

Obviously my current path is empty….. Hundreds of grass mud horses have run

When you see vcexpress, do you think you need to install it?In fact, you can install a special report for Python 2.7. The path is as follows: https://www.microsoft.com/en-us/download/details.aspx?id=44266

When you are happy to install it, and then you feel that it’s done, but it’s not an egg, because this installation will not automatically help you register in the registry… And it has to be installed in the user directory, so you can only search the vcvarsall.bat location. Here is my path:

C:\Users\username\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0

How to solve this problem, human flesh plus chant:

error reason:
the reason for this error is that msvc9compiler.py in Python’s distutils module does not search for ‘vcvarsall. Bat’ from the path specified by the environment variable, but through the registry… However, I do not know why the compiler installation process does not configure the registry

solution:
just manually configure the registry
// 1. Open the registry editor
Run regedit
// 2. Configure
// 2.1. If you install 32-bit python, create the following key:
HKEY_ CURRENT_ User/software/Microsoft/Visual Studio/9.0/setup/VC
// 2.2. If you have 64 bit Python installed, create the following:
HKEY_ CURRENT_ 3. Create a new string value under this item:
Name: productdir
data: path of vcfarsall.bat
note: the last backslash is not included in the path

The solutions are as follows:

http://stackoverflow.com/questions/6551724/how-do-i-point-easy-install-to-vcvarsall-bat

http://blog.csdn.net/donger_ soft/article/details/44838109

PyCrypto Install error: Unable to find vcvarsall.bat

Today, there is a wechat SDK library called wechatpy, in which a dependency library is pycrypt

If you directly PIP install wechatpy, you will encounter error: unable to find vcvarsall.bat

Google, a bunch of solutions, are invalid, should be expired

Then I found two good articles

1. It introduces Microsoft Visual C + + compiler for Python 2.7

http://www.microsoft.com/en-us/download/details.aspx?id=44266

2. It introduces that if the version of setuptools is higher than 6.0, the compiler can be searched automatically

http://stackoverflow.com/questions/26140192/microsoft-visual-c-compiler-for-python-2-7

 

Then, first install 1, then check your own setup tools, version 3.6, and decisively upgrade to 7.0

pipinstall--upgradesetuptools

Then PIP install wechatpy again, everything goes well

Record it