简单解决python安装中的Unable to find vcv

2020-10-10  本文已影响0人  殇不患_531c

配置环境时出现这个问题,原因是没有找到vcvarsall.bat。这个文件实际上的visual stdio中的,在vs的安装目录中找到VC\Auxiliary\Build\vcvarsall.bat,复制完整路径。python查询这个文件的方法在_msvccompiler.py文件中的_find_vcvarsall方法
我使用的是conda的虚拟环境,因此进入conda安装目录的对应env中\Lib\distutils_msvccompiler.py文件中,修改:

def _find_vcvarsall(plat_spec):
        best_dir = r'E:\tools\vs2017\VC\Auxiliary\Build'
        best_version = 17
        vcruntime = None
        vcruntime_spec = _VCVARS_PLAT_TO_VCRUNTIME_REDIST.get(plat_spec)
        if vcruntime_spec:
            vcruntime = os.path.join(best_dir,
                vcruntime_spec.format(best_version))
            if not os.path.isfile(vcruntime):
                log.debug("%s cannot be found", vcruntime)
                vcruntime = None
        print(vcruntime)
        return r'E:\tools\vs2017\VC\Auxiliary\Build\vcvarsall.bat', 
#上面这行改成你vs中vcvarsall.bat的路径
vcruntime
上一篇下一篇

猜你喜欢

热点阅读