question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Obsolete error message when MS Visual C++ Build Tools missing

See original GitHub issue

Environment

  • pip version: 20.2.1
  • Python version: 3.8.3
  • OS: Windows 10 (fully patched, on latest release)

Description

When installing a module that needs Microsoft’s Visual C++ Build Tools, and these tools are not present, this message is displayed: error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

This message is erroneous for a few reasons:

In my case, I no longer got this error after adding C++ support to my Visual Studio 2017 installation per the link above. That validates that:

  1. the build tools can be installed as a component of Visual Studio instead of separately
  2. version 14 is not strictly required (Visual Studio 2017 = version 15.9.25)

Expected behavior

Error message wording should be accurate and not encourage undesirable choices.

How to Reproduce

Install a package that needs to be compiled with C++. For example: python -m pip install wordcloud

Output

The output ends with this:

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jaracocommented, Aug 16, 2020

Feel free to send a PR. The code is here.

1reaction
BoarGulescommented, Oct 8, 2020

The remark “version 14 is not strictly required” is quite untrue in practice.

Method MSVCCompiler.query_vcvarsall() determines if there is a compiler installed by searching for the file vcvarsall.bat, which exists in 14.2. Failing that, it then recommends the user download Visual C++ 14.2, which is no longer readily available. It can be downloaded, but only if you have a paid subscription. The link in the error message points to https://visualstudio.microsoft.com/downloads/ which does indeed work, but the only compiler available free from that page is Visual Studio 2019 (a.k.a. version 16). That compiler does not satisfy the query_vcvarsall() test because the counterpart of vcvarsall.bat in 16.0 is VsDevCmd.bat.

In fact even if you have VC++ 14.2, distutils still gets things wrong, presumably holdovers from earlier versions of VC++. First one must work out the correct values for environment variables LIBPATH and INCLUDE. After that, to make a compile work using the command lines that distutils issues, it is also necessary to copy the contents of C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64 and C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64 to a new folder Pythonxx\PCBuild\amd64 which distutils puts as a LIBPATH parameter to link.exe but which does not actually exist. Likewise it is necessary to copy C:\Program Files (x86)\Windows Kits\10\bin\x64\rc.exe to an existing folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64 because distutils knows the executable is there but Microsoft reckons otherwise.

All of this probably a doddle if you are a seasoned MSC programmer, but (I speak from experience) painful to someone who switched from C to Python around the time when Visual C 3 came out. And quite out of reach for a Python beginner who gets this message from PIP when he tries to install numpy. That happened today.

So it is not just the message that is obsolete: the whole of distutils.msvc9compiler needs attention paid not just to what it says but to what it does. It is of course entitled to insist on one and only one MS compiler to do what it does, but it must be one that is readily available, and the command lines it issues should work on a vanilla installation of that compiler, without the user having to modify the folder layout to put files where distutils expects them to be.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Obsolete error message when MS Visual C++ Build Tools ...
In my case, I no longer got this error after adding C++ support to my Visual Studio 2017 installation per the link above....
Read more >
Unable to install Visual C++ build tools - Microsoft Q&A
It seems that your installation package is corrupted or damaged. Please try to download the Visual C++ Build Tools from Microsoft download page ......
Read more >
Fixed: Microsoft Visual C++ 14.0 Is Required Error
As hinted by the error message, the main reason is often related to the Microsoft Visual C++ Build Tools. Sometimes, the corrupted installation...
Read more >
npm install error - MSB3428: Could not load the Visual C++ ...
What I have tried: Install whatever dependencies it needs. (ursa, node-gyp etc) Install Visual C++ 2005. Install Visual C++ 2010. Change the enviroment...
Read more >
Visual Studio not able to compile a simple Hello World
I created a new CMake project. Did not even touch in the code, and I am getting the following Error. NOTE: This problem...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found