felixrieseberg / windows-build-tools

:package: Install C++ Build Tools for Windows using npm
MIT License
3.4k stars 237 forks source link

Python 2.7.16 installed already, installs 2.7.15 anyways #191

Closed keithnbrown closed 4 years ago

keithnbrown commented 5 years ago

I have python 2.7.16 installed installed for all users at c:\python27, and 3.7.4 installed for all users in c:\python37

Both of those and thier respective "scripts" subdirectories are in my path.

Yet when i run this npm installer, it installs 2.7.15 as if i didn't have python already. I'm fairly lucky my python was installed for all users, otherwise this would have taken precidence in the path.

Why can this not find my already-installed python 2.7.16? My guess is that it sees my python 3 install and goes "I need python 2 though, so i'll install it" without checking to see if i have python 2 beneath it. Either that or it's looking for the 2.7.15 version specifically, finds my 2.7.16 install and deems it unusable

What can be done here?

felixrieseberg commented 5 years ago

Hm, that sounds like a bug - we check if Python is installed by running python -v. Could you run that on your machine and tell me that the output is?

keithnbrown commented 5 years ago

Python 3.7.4 or Python 2.7.16 if i have that earlier in my PATH

keithnbrown commented 5 years ago

to clarify, I default to 3, so that will be the one it sees

DestinyHunter commented 5 years ago

I have the same problem

xmedeko commented 5 years ago

@keithnbrown @DestinyHunter you must have Python 2.7 in your PATH (before python 3), so python -V must return Python 2.7.xx. Or use virtualenvwrapper-win to switch to Python 2 just for your project.

@felixrieseberg It would be ideal if the Windows Python py.exe utility could be used, i.e. py -2.7 -V.

Also, the code should check npm config get python and do not install python if it's already set? Or maybe some switch to skip python could be enough.

keithnbrown commented 5 years ago

@xmedeko That shouldn't be a requirement. I use Python 3 as my daily version, and as python 2 is near EOL, this code should use (or at least be aware of) python 3, and be more inteligent in how it is detected.

Windows has option of the py version selector if it was installed when python 3 was installed. So simply checking for that and querying if python 2 is installed though it would be a good start

xmedeko commented 5 years ago

@keithnbrown I've written the comment to you as a workaround for the current version. Next, I've written to @felixrieseberg suggestion "It would be ideal ..." for future - and that's similar what you have written.

keithnbrown commented 5 years ago

I only read the bit directed at myself, so yes i missed the suggestion. But a workaround like that is simply not on, espeicailly with less than 4 months until EOL and when the py version selector has existed for longer. This should use python 3 by the new year, not just be altered the prevent this issue but still use 2

xmedeko commented 5 years ago

windows-build-tools just install necessary stuff for node-gyp. node-gyp requires python2, windows-build-tools cannot change it.

keithnbrown commented 5 years ago

ugh, fair enough, and i jsut read their readme, they're explicity not supporting pyhton 3 for some reason

Dragory commented 5 years ago

Node-gyp seems to support Python 3 now. They recommend installing the official release from the Microsoft store, but I assume windows-build-tools would still install it normally?

Josverl commented 5 years ago

indeed according to : https://github.com/nodejs/node-gyp#option-2 python 3 will work fine and python 2.7 is no longer needed. (Thanks for all the work on that; It was good while it lasted)