Python 安装 包时 VC 14 找不到错误终极解决办法

本文介绍了一种解决python环境下使用setup.py构建wheel包时出现错误的方法。通过修改setuptools库中的msvc.py文件,绕过了查找Visual Studio安装路径的过程,直接指定了VC编译器的位置。

python setup.py bdist_wheel did not run successfully.

修改源码:M:\work\tool\Python39x64\Lib\site-packages\setuptools\msvc.py

中 函数 def _msvc14_find_vc2017():

下代码:

    try:
        path = subprocess.check_output([
            join(root, "Microsoft Visual Studio", "Installer", "vswhere.exe"),
            "-latest",
            "-prerelease",
            "-requiresAny",
            "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
            "-requires", "Microsoft.VisualStudio.Workload.WDExpress",
            "-property", "installationPath",
            "-products", "*",
        ]).decode(encoding="mbcs", errors="strict").strip()
    except (subprocess.CalledProcessError, OSError, UnicodeDecodeError):
        return None, None

为:

    # try:
        # path = subprocess.check_output([
            # join(root, "Microsoft Visual Studio", "Installer", "vswhere.exe"),
            # "-latest",
            # "-prerelease",
            # "-requiresAny",
            # "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
            # "-requires", "Microsoft.VisualStudio.Workload.WDExpress",
            # "-property", "installationPath",
            # "-products", "*",
        # ]).decode(encoding="mbcs", errors="strict").strip()
    # except (subprocess.CalledProcessError, OSError, UnicodeDecodeError):
        # return None, None
    path="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0"

由于安装的精简版本没有Installer目录及相关文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值