Obsolete error message when MS Visual C++ Build Tools missing
See original GitHub issueEnvironment
- 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:
- There is no such product at https://visualstudio.microsoft.com/downloads/. I think https://visualstudio.microsoft.com/visual-cpp-build-tools/ is the correct URL.
- Version 14 probably not required. It may be a minimum requirement, not absolute. That should be validated before updating the language.
- People who already have Visual Studio installed probably should modify their installation instead of downloading build tools. The warning message doesn’t say that. If you install build tools along with Visual Studio, you may run into issues.
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:
- the build tools can be installed as a component of Visual Studio instead of separately
- 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:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Feel free to send a PR. The code is here.
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 filevcvarsall.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 tohttps://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 thequery_vcvarsall()
test because the counterpart ofvcvarsall.bat
in 16.0 isVsDevCmd.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 thatdistutils
issues, it is also necessary to copy the contents ofC:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64
andC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64
to a new folderPythonxx\PCBuild\amd64
whichdistutils
puts as a LIBPATH parameter tolink.exe
but which does not actually exist. Likewise it is necessary to copyC:\Program Files (x86)\Windows Kits\10\bin\x64\rc.exe
to an existing folderC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
becausedistutils
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 wheredistutils
expects them to be.