python sys.executable inconsistency if called from cmd
Lemke, Michael SF/HZA-ZIC2
Wed Feb 3 16:17:41 GMT 2021
On Wednesday, February 3, 2021 4:28 PM Andrey Repin wrote:
>Greetings, Lemke, Michael SF/HZA-ZIC2!
>> I don't know anything about python but want to use cygwin's
>> python from nodejs npm with node-gyp. The node-gyp module is trying to
>> find the python executable path from sys.executable and fails.
>If that's true, then it should be fixed upstream.
Good to know but I doubt that they will. For those who need this -
here is a workaround for node-gyp v5.1.0 I just found:
cygwin> mkdir /c/Python37
cygwin> ln `which python3.6m` /c/Python37/python.exe
I aware of the version clash here but c:\Python37 is one of a
few explicit locations this node-gyp looks at. Doesn't seem
confused if the versions don't match. The file you link to
must be the actual Cygwin executable not any of the python
links in /bin.
>> While investigating this I found this to me quite inconsistent
>> cygwin> /bin/python3.6m.exe -c 'import sys; print(sys.executable);'
>> cygwin> python3.6m -c 'import sys; print(sys.executable);'
>> cygwin> python3.6 -c 'import sys; print(sys.executable);'
>> cygwin> python3.6m.exe -c 'import sys; print(sys.executable);'
>> cmd> c:/MyStuff/NCygwin64/bin/python3.6m.exe -c 'import sys; print(sys.executable);'
>> cmd> rem add cygwin path to Windows:
>> cmd> path %PATH%;c:\MYSTUFF\ncygwin64\bin
>> cmd> python3.6m.exe -c 'import sys; print(sys.executable);'
>> With CMD I'll never get an executable that actually works from cmd.
>> Is this expected?
>Yes. This is Cygwin, not Windows CMD.
Sure but python seems to start just fine under cmd and it does do
some gyrations with sys.executable dependent on calling environment.
So this looks somewhat fishy to me.
>> Is there a way around to make this work?
>Yes, write scripts correctly, correctly translate paths.
More information about the Cygwin