1

我有一个 python 包由于依赖于 Windows 构建工具而无法安装。

我尝试过的事情:

  1. 安装最新版本的 Visual Studio 2017(AFAIK 它应该包含 Microsoft Visual C++ 14.0)。

  2. 直接从此处https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017安装 Visual Studio 2017 的构建工具。

  3. 明确C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools地走上我的道路。

  4. 卸载所有 Visual Studio 并重试。

到目前为止还没有运气。我尝试重新启动终端,重新启动计算机等......我正在使用 GitBash,这可能是相关的,尽管它不会给我带来任何问题。

当我安装这些工具时,我确保检查了“Visual C++ Build Tools”工作流,它选择了“单个组件”选项卡下可用的许多行项目的一部分。

在下面的示例中,我正在安装语言模型,但我相信我的问题比这更普遍。我发现很难理解许多组件中的哪些与我的任务相关。我想知道的是:我如何验证我是否正确配置了构建工具并且我有正确的版本?这里的任何建议或指导将不胜感激。

错误:

$ pip36 install https://github.com/kpu/kenlm/archive/master.zip
Collecting https://github.com/kpu/kenlm/archive/master.zip
  Downloading https://github.com/kpu/kenlm/archive/master.zip (526kB)
Installing collected packages: kenlm
  Running setup.py install for kenlm: started
    Running setup.py install for kenlm: finished with status 'error'
    Complete output from command c:\users\ks99999999\appdata\local\programs\python\python36-32\python.exe  -u -c "import setuptools, tokenize;__file__='C:\\Users\\ks99999999\\AppData\\Local\\Temp\\pip-tfn5ym94-b uild\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close ();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ks99999999\AppData\Local\Temp\pip-r2e ogfmd-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'kenlm' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http: //landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command "c:\users\ks99999999\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptool s, tokenize;__file__='C:\\Users\\ks99999999\\AppData\\Local\\Temp\\pip-tfn5ym94-build\\setup.py';f=getatt r(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __ file__, 'exec'))" install --record C:\Users\ks99999999\AppData\Local\Temp\pip-r2eogfmd-record\install-rec ord.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ks99999999\Ap pData\Local\Temp\pip-tfn5ym94-build\
4

1 回答 1

2

Microsoft Visual Studio 不随任何 VC 编译器(或通常的任何编译器)一起提供开箱即用。您的安装是模块化的,因此您必须确保您确实安装了 Visual c++ 与您的 VS2017 安装。此外,IIRC、VS2017 附带 Microsoft Visual C++ 15.0。 您可以使用独立的 Microsoft Visual Studio 2015 构建工具安装 14.0 编译器。确保您也有正确的 setuptools 版本。

您可以通过查看开始菜单 -> 添加/删除程序并检查已安装程序列表来检查安装了哪个版本的 MSVC。

于 2018-03-26T18:41:42.850 回答