zoukankan      html  css  js  c++  java
  • solution for "cannot find vcvarsall.bat" in Python

    When building some package with python in windows, the command is

    python setup.py build

    However, if you use Visual Studio as the compiler, sometime there is an error shown as :

    error: Unable to find vcvarsall.bat

    But VS has been installed in this computer, has not it?

    The error is from a logical error in the distutils of python.
    In the file of msvc9compiler.py, there is a function called: get_build_version. In this function is used to get the version of VS that is used to build your python, and the value are used as the VS version in your computer. It does not make sense at all!

    A solution is to find the version of VS in your computer from register. The code as followed:


    def get_build_version():
    """Return the version of MSVC in your computer.
    """
    p = r"Software\Wow6432Node\Microsoft\VisualStudio"
    for base in HKEYS:
    try:
    h = RegOpenKeyEx(base, p)
    except RegError:
    continue
    key = RegEnumKey(h, 0)
    if key:
    return float(key)
    return None
  • 相关阅读:
    第一次作业
    第0次作业
    第14、15周作业
    第七周作业
    第六周作业
    第四周作业
    第三周作业
    第4次作业
    第3次作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/xueliangliu/p/2962165.html
Copyright © 2011-2022 走看看