Windows: subprocess won't run different Python interpreter

eryk sun eryksun at gmail.com
Fri Nov 11 04:55:23 EST 2016


On Fri, Nov 11, 2016 at 8:56 AM, Thorsten Kampe
<thorsten at thorstenkampe.de> wrote:
> * eryk sun (Fri, 11 Nov 2016 06:23:50 +0000)
>>
>> That's the application directory, which is the first place
>> CreateProcess looks (via the SearchPath call), as both of my examples
>> shows. In my case python.exe is located in the standard 3.5 system
>> installation path, "C:\Program Files\Python35".
>
> Okay, it looks like I read your first answer not thorough enough.
>
> So if the application's directory is always searched then the issue
> should be reproducible with any native (non-Cygwin) Windows
> interpreter:
>
> """
> tcc> \PortableApps\TCC_RT\tcc.exe /c run-TEST.btm
> unset PATH
> tcc.exe /c ver
> TCC: C:\Documents\batch\run-TEST.btm [2]  Unbekannter Befehl
> "tcc.exe"
> """
>
> So TCC can't find itself with an empty PATH. That's how Python
> (subprocess) should also work.

If it works like cmd.exe, then it does its own search using %Path% and
%PathExt%. For example:

    C:\>cmd /c "set "PATH=" & cmd"
    'cmd' is not recognized as an internal or external command,
    operable program or batch file.

But why should subprocess.Popen implement its own search like the
shell instead of relying on CreateProcess to search for the
executable? You'd have to come up with an argument to convince the
devs to change the behavior in 3.7.



More information about the Python-list mailing list