【发布时间】:2018-03-26 18:25:25
【问题描述】:
我有一个 python 包由于依赖于 Windows 构建工具而无法安装。
我尝试过的事情:
安装最新版本的 Visual Studio 2017(AFAIK 它应该包含 Microsoft Visual C++ 14.0)。
直接从此处https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017 安装适用于 Visual Studio 2017 的构建工具。
明确地将
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools放在我的路径上。卸载所有 Visual Studio 并重试。
到目前为止还没有运气。我尝试重新启动终端,重新启动计算机等...我正在使用 GitBash,这可能是相关的,尽管它不会给我带来任何问题。
当我安装这些工具时,我确保检查了“Visual C++ 构建工具”工作流,该工作流选择了“单个组件”选项卡下可用的许多行项目的一部分。
在下面的示例中,我正在安装一个语言模型,但我相信我的问题比这更普遍。我发现很难理解许多组件中的哪些与我的任务相关。我想知道的是:如何验证我是否正确配置了构建工具并且我有正确的版本?任何建议或指导将不胜感激。
错误:
$ 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\
【问题讨论】:
-
您是否已将其添加到您的 Windows PATH 或您的 bash 路径中?
-
你使用的是什么版本的
setuptools? -
安装后是否尝试过重启?另外,你确定安装构建工具后错误是一样的吗?
-
另外,Visual C++ 14 在 VS 15 中,而不是在 VS 17 中。由于明确要求 14.0,我有一些实例不能与 VS 17 一起使用; This link worked for me
-
@Priansh 我在高级设置下将它添加到我的 PATH 环境变量中。
标签: python windows build-tools kenlm