pythonwindowsbuild-toolskenlm

Installing Python package from source using Microsoft Visual Build Tools 2017


I have a python package that is failing to install due a dependency on Windows build tools.

Things I have tried:

  1. Install latest version of Visual Studio 2017 (AFAIK it should contain Microsoft Visual C++ 14.0).

  2. Install Build Tools for Visual Studio 2017 directly from here https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017.

  3. Put C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools on my path explicitly.

  4. Uninstall all of Visual Studio and try again.

So far no luck. I tried restarting the terminal, restarting the computer etc... I am using GitBash, which might be relevant, although it never causes me any problems otherwise.

When I installed the tools, I made sure to check the 'Visual C++ Build Tools' workflow which selected some subset of the many line items that were available under the Individual Components tab.

In my example below I'm installing a language model but I believe that my issue is more general than that. I'm finding it difficult to understand which of the many components are relevant to my task. What I would like to know is: how do I validate that I have the build tools configured correctly and that I have the correct version? Any advice or guidance here would be much appreciated.

error:

$ 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\

Solution

  • Microsoft Visual Studio doesn't ship out-of-box with any VC compiler (or any compiler generally). Your installation is modularized, so you will have to make sure that you did, in fact, install a visual c++ with your installation of VS2017. Moreover, IIRC, VS2017 ships with Microsoft Visual C++ 15.0. You can install the 14.0 compiler with the Standalone Microsoft Visual Studio 2015 build tools. Make sure you have the correct setuptools version as well.

    You can check which version of MSVC is installed by looking at Start Menu -> Add / Remove Programs and checking in the list of installed programs.