classification
Title: Distutils should generate a better error message when the SDK is not installed
Type: behavior Stage: resolved
Components: Distutils, Windows Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Ilya Kamenshchikov, Ivan.Pozdeev, Karl Stahl, Lars.H, Matt.Hickford, cdavid, dstufft, eric.araujo, lambda, mdengler, n, piotr.dobrogost, pokeeffe, ralf.gommers, ssc, steve.dower, tarek, vivekkarumudi, vstinner, waldhol
Priority: low Keywords: patch

Created on 2008-05-22 11:33 by cdavid, last changed 2021-02-03 18:21 by steve.dower. This issue is now closed.

Files
File name Uploaded Description Edit
issue2943.diff n, 2013-03-18 19:33 review
Messages (20)
msg67187 - (view) Author: Cournapeau David (cdavid) Date: 2008-05-22 11:32
I tried to build some extensions with python 2.6 (built from sources
with VS 2008 express), and got some errors in the function
query_vcvarsall. The offending lines are:

if len(result) != len(interesting):
    raise ValueError(str(list(result.keys())))

I got a value error here. After some investigation, I realized that it
was because I did not install the SDK. I think the error message could
be isgnificantly improved if installing the SDK was suggested in the
exception message.
msg85578 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-04-05 22:16
Does it mean you won't get the settings for "include", "lib", "libpath"
and "path" when you call vcvarsall.bat *only* of the SDK is not
installed, or can't we have other cases ?

If the latter is true, maybe a better formatted Error message where
we list founded values and the list of missing values.
msg85685 - (view) Author: Cournapeau David (cdavid) Date: 2009-04-07 04:44
Hi tarek,

I can't say for sure about the only part. My experience on windows is
that there are so many possible combinations that getting it right is
difficult.

But in any case, the raised exception is not helpful. I am a developer
and familiar with distutils, and I could not make any sense of the
message. If the cause cannot be determined, at least a message like
"Unexpected result while detecting MS toolchain (str(result) vs
str(interesting)" would be helpful I think.

Also, but I am not 100 % sure about this, I believe any exception raised
within distutils should be inherited from DistutilsError
msg184500 - (view) Author: Ned Jackson Lovely (n) * Date: 2013-03-18 19:33
Improved msg per discussion.

I don't see how to test this without messing with the windows registry. I am deeply reluctant to do that.
msg193630 - (view) Author: Matt Hickford (Matt.Hickford) * Date: 2013-07-24 09:00
( Upstreamed from Pip https://github.com/pypa/pip/issues/942 )

There are lot of Python users on Windows. If they succeed in installing a package manager (a struggle), this is typically their first experience with it

    $ pip install numpy

    blah blah blah

    Error: Unable to find vcvarsall.bat

The misery is compounded by the cryptic error message. They don't know whether the problem with their computer, the specific package, or pip generally. Let alone how to fix it.

You and I know this happens because the package install involves building some C code from source and the user doesn't have a C compiler installed. The fix is to install mingw32 (or Visual Studio) and edit distutils.cfg to specify to use that compiler. 

Thus, it would be really helpful to print a message after 'error: unable to find vcvarsall.bat' such as

> Installing this package requires a C compiler. To fix this error, follow http://stackoverflow.com/q/2817869/284795
msg203440 - (view) Author: Matt Hickford (Matt.Hickford) * Date: 2013-11-19 22:47
For comparison, Ruby ships with a package manager, Gem. If a user tries to install a package with C extensions, they are given this user-friendly message:

> Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
msg207147 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-01-02 08:28
How about "Error: vcvarsall.bat not found - VC++ not installed or wrong version" ?
msg207159 - (view) Author: Holger Waldmann (waldhol) Date: 2014-01-02 12:03
On Python 3.3.3 it is even worse.
I am using Python 3.3.3 (32bit) on Windows 7 (64bit).
Visual Studio C++ 2008 Express Edition is properly installed.

Note: I use Python 32bit because Visual Studio C++ 2008 Express Edition includes only the 32bit compiler.

Using Google I did find the instructions on http://stackoverflow.com/q/2817869/284795
But they were of no help.

There are two problems that are not addressed.

Problem #1:
distutils/msvc9compiler.py decides to look for the 32bit registry key (because it is a 32bit Python) but it should look for the 64bit registry key (because it is a 64bit Windows).

Problem #2:
distutils/msvc9compiler.py decides to look for VERSION=10
I did some reverse engineering on the module to find this information.
Why is this not documented?

After setting VS100COMNTOOLS=%VS90COMNTOOLS% everything worked fine.
msg220775 - (view) Author: Lars H (Lars.H) Date: 2014-06-16 22:01
+1 vote for fixing this problem. Matt Hickford said it very well... the error message is very cryptic, not giving the user a clue as to what domain the problem lies in.
msg220776 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-16 22:18
@Steve could this be included with the work you're doing with the Windows installers?
msg220782 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-06-17 00:08
I can certainly improve this for 3.5 as part of the move to VC14 (which will require changes to distutils anyway). The installer won't touch it.

For earlier Python versions, I'd quite like to see setuptools take over detection from distutils and provide the better error message. I have some other work going on (currently, mostly, still in secret) that may help here, so I may be the one to contribute it to setuptools too if things go well.
msg229392 - (view) Author: John (lambda) Date: 2014-10-15 01:33
error message should contain more details about what went wrong and why
msg257290 - (view) Author: Ilya Kamenshchikov (Ilya Kamenshchikov) * Date: 2016-01-01 13:30
please fix spent half a day to understand I need C compiler
msg263206 - (view) Author: Ivan Pozdeev (Ivan.Pozdeev) * Date: 2016-04-11 21:01
The vsvarsall.bat message should direct to https://wiki.python.org/moin/WindowsCompilers rather than some 3rd-party site (even more so, one with user-generated content like SO).

E.g.: "Unable to find vcvarsall.bat. A required version of MS VC++ compilers is not installed or used improperly. See https://wiki.python.org/moin/WindowsCompilers for instructions."
msg279501 - (view) Author: Vivek Karumudi (vivekkarumudi) Date: 2016-10-26 15:45
I cannot understand the cryptic message could you please change it to something meaningful for "Unable to find vcvarsall.bat"
msg279502 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-10-26 15:59
Idea: add a link to this article:
https://aka.ms/vcpython
or full link: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/

Related tweet from Steve Dower:
https://twitter.com/zooba/status/791032320006328320
msg279514 - (view) Author: Ivan Pozdeev (Ivan.Pozdeev) * Date: 2016-10-26 21:51
@haypo, as I said, it's undesirable to link to a 3rd party site in a built-in error message because its availability and content are outside the dev team's control.
msg279516 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-10-26 22:03
Maybe we can add an entry to the Python FAQ, use this link and then add a
link to the Microsoft article.
msg279612 - (view) Author: Ivan Pozdeev (Ivan.Pozdeev) * Date: 2016-10-28 16:49
What's wrong with the Python wiki link in msg263206 above? It is supposed to be _the_ guide for setting up compilers in Windows, isn't it?

Ideally, this should be a link to `distutils' docs - because, you know, the wiki isn't carved in stone, either, while the docs for the specific version are bundled with it.

Actually, `distutils' does have an entry on `distutils.msvccompiler': https://docs.python.org/2/distutils/apiref.html#module-distutils.msvccompiler . It even documents the use of DUSTUTILS_USE_SDK variable!
The wording could use some clarification and maybe a link to wiki, but that's for another ticket.
msg386359 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:21
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2021-02-03 18:21:28steve.dowersetstatus: open -> closed
resolution: out of date
messages: + msg386359

stage: resolved
2016-10-28 16:49:49Ivan.Pozdeevsetmessages: + msg279612
2016-10-26 22:03:38vstinnersetmessages: + msg279516
2016-10-26 21:51:04Ivan.Pozdeevsetmessages: + msg279514
2016-10-26 15:59:22vstinnersetmessages: + msg279502
2016-10-26 15:45:58vivekkarumudisetnosy: + vivekkarumudi
messages: + msg279501
2016-04-11 21:01:20Ivan.Pozdeevsetnosy: + Ivan.Pozdeev
messages: + msg263206
2016-04-01 19:26:04vstinnersetnosy: + vstinner
2016-03-31 05:34:27BreamoreBoysetnosy: - BreamoreBoy
2016-03-30 22:22:30Karl Stahlsetnosy: + Karl Stahl
2016-01-01 13:30:05Ilya Kamenshchikovsetnosy: + Ilya Kamenshchikov
messages: + msg257290
2015-05-03 19:56:07ralf.gommerssetnosy: + ralf.gommers
2015-04-11 12:24:41sscsetnosy: + ssc
2014-10-30 20:11:18pitrousetassignee: tarek ->
2014-10-15 01:33:48lambdasetnosy: + lambda
messages: + msg229392
2014-09-11 07:06:41piotr.dobrogostsetnosy: + piotr.dobrogost
2014-08-30 04:23:49terry.reedysetversions: + Python 3.4, Python 3.5, - Python 3.1, Python 3.2, Python 3.3
2014-07-02 11:32:04mdenglersetnosy: + mdengler
2014-06-20 06:26:14pokeeffesetnosy: + pokeeffe
2014-06-17 00:08:00steve.dowersetmessages: + msg220782
2014-06-16 22:18:15BreamoreBoysetnosy: + BreamoreBoy, eric.araujo, dstufft, steve.dower
messages: + msg220776
components: + Windows
2014-06-16 22:01:49Lars.Hsetnosy: + Lars.H
messages: + msg220775
2014-02-03 15:38:36BreamoreBoysetnosy: - BreamoreBoy
2014-01-02 12:03:14waldholsetnosy: + waldhol

messages: + msg207159
versions: + Python 3.2, Python 3.3
2014-01-02 08:28:15BreamoreBoysetnosy: + BreamoreBoy
messages: + msg207147
2013-11-19 22:47:52Matt.Hickfordsetmessages: + msg203440
2013-07-24 09:00:44Matt.Hickfordsetnosy: + Matt.Hickford
messages: + msg193630
2013-03-18 19:33:52nsetfiles: + issue2943.diff

nosy: + n
messages: + msg184500

keywords: + patch
2009-04-07 04:44:51cdavidsetmessages: + msg85685
2009-04-05 22:16:43tareksetpriority: low

messages: + msg85578
2009-02-06 09:14:44tareksetassignee: tarek
type: behavior
nosy: + tarek
versions: + Python 3.1, Python 2.7
2008-05-22 11:33:00cdavidcreate