Python path on windows
Dave Angel
davea at davea.name
Fri Feb 20 09:51:53 EST 2015
On 02/20/2015 09:43 AM, loial wrote:
> On Linux we use
> #!/usr/bin/env python
>
> At the start of scripts to ensure that the python executable used is the one defined in the PATH variable, rather than hardcoding a path to the python executable.
>
> What is the equivalent functionality in Windows?
>
Depends on Python version. In newer versions, there is a py.exe file
which they put on their path. Then in the registry is a two-stage
association between the .py and .pyw extensions and the above executable.
Finally, when py.exe starts, it reads that first (shebang) line, and
decides which python interpreter to actually use.
One problem I've heard about is that if someone installs 2.7 on top of
3.x, it can wipe out the file associations, and mess this stuff up.
The py.exe can be separately installed, to use on older python versions.
This all happened after I cut loose from Windows.
--
DaveA
More information about the Python-list
mailing list