Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85973 > unrolled thread

Python path on windows

Started byloial <jldunn2000@gmail.com>
First post2015-02-20 06:43 -0800
Last post2015-02-22 01:40 +1100
Articles 12 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  Python  path on windows loial <jldunn2000@gmail.com> - 2015-02-20 06:43 -0800
    Re: Python  path on windows Dave Angel <davea@davea.name> - 2015-02-20 09:51 -0500
    Re: Python path on windows Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-20 07:54 -0700
      Re: Python path on windows loial <jldunn2000@gmail.com> - 2015-02-20 07:16 -0800
        Re: Python path on windows Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-20 11:25 -0700
        Re: Python path on windows Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-20 18:31 +0000
        Re: Python path on windows Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-02-20 21:32 +0100
    Re: Python  path on windows wxjmfauth@gmail.com - 2015-02-20 07:20 -0800
    Re: Python path on windows Gisle Vanem <gvanem@yahoo.no> - 2015-02-21 12:05 +0100
    Re: Python path on windows Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-21 12:36 +0000
    Re: Python path on windows Dave Angel <davea@davea.name> - 2015-02-21 09:10 -0500
    Re: Python path on windows Chris Angelico <rosuav@gmail.com> - 2015-02-22 01:40 +1100

#85973 — Python path on windows

Fromloial <jldunn2000@gmail.com>
Date2015-02-20 06:43 -0800
SubjectPython path on windows
Message-ID<f8c8a373-16e9-41c1-9e5b-37003f7a6c70@googlegroups.com>
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?

[toc] | [next] | [standalone]


#85974

FromDave Angel <davea@davea.name>
Date2015-02-20 09:51 -0500
Message-ID<mailman.18923.1424443933.18130.python-list@python.org>
In reply to#85973
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

[toc] | [prev] | [next] | [standalone]


#85975 — Re: Python path on windows

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-02-20 07:54 -0700
SubjectRe: Python path on windows
Message-ID<mailman.18924.1424444054.18130.python-list@python.org>
In reply to#85973

[Multipart message — attachments visible in raw view] — view raw

On Feb 20, 2015 7:46 AM, "loial" <jldunn2000@gmail.com> 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?

https://docs.python.org/3/using/windows.html#launcher

Note that while the launcher can be used with any version of Python, it is
only packaged with 3.3+.

[toc] | [prev] | [next] | [standalone]


#85977 — Re: Python path on windows

Fromloial <jldunn2000@gmail.com>
Date2015-02-20 07:16 -0800
SubjectRe: Python path on windows
Message-ID<ef789d3d-ec7d-4b6f-a6a9-751a7a945851@googlegroups.com>
In reply to#85975
On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote:
> On Feb 20, 2015 7:46 AM, "loial" <jldun...@gmail.com> 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?
> 
> https://docs.python.org/3/using/windows.html#launcher
> 
> Note that while the launcher can be used with any version of Python, it is only packaged with 3.3+.

Vesrion is 2.6

[toc] | [prev] | [next] | [standalone]


#85984 — Re: Python path on windows

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-02-20 11:25 -0700
SubjectRe: Python path on windows
Message-ID<mailman.18928.1424456749.18130.python-list@python.org>
In reply to#85977
On Fri, Feb 20, 2015 at 8:16 AM, loial <jldunn2000@gmail.com> wrote:
> On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote:
>> On Feb 20, 2015 7:46 AM, "loial" <jldun...@gmail.com> 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?
>>
>> https://docs.python.org/3/using/windows.html#launcher
>>
>> Note that while the launcher can be used with any version of Python, it is only packaged with 3.3+.
>
> Vesrion is 2.6

You can install multiple versions of Python on the same system without
conflict. If you install Python 3.4 also, then you'll have the
launcher. I don't know if there's an easy way to install just the
launcher.

[toc] | [prev] | [next] | [standalone]


#85985 — Re: Python path on windows

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-02-20 18:31 +0000
SubjectRe: Python path on windows
Message-ID<mailman.18929.1424457100.18130.python-list@python.org>
In reply to#85977
On 20/02/2015 15:16, loial wrote:
> On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote:
>> On Feb 20, 2015 7:46 AM, "loial" <jldun...@gmail.com> 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?
>>
>> https://docs.python.org/3/using/windows.html#launcher
>>
>> Note that while the launcher can be used with any version of Python, it is only packaged with 3.3+.
>
> Vesrion is 2.6
>

See https://bitbucket.org/vinay.sajip/pylauncher

As an aside it looks from the formatting above as if you're using google 
groups to post.  If that is the case would you please access this list 
via https://mail.python.org/mailman/listinfo/python-list or read and 
action this https://wiki.python.org/moin/GoogleGroupsPython to prevent 
us seeing double line spacing and single line paragraphs, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#85992 — Re: Python path on windows

FromWolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de>
Date2015-02-20 21:32 +0100
SubjectRe: Python path on windows
Message-ID<mailman.18933.1424464361.18130.python-list@python.org>
In reply to#85977
On 20.02.2015 19:25, Ian Kelly wrote:
> On Fri, Feb 20, 2015 at 8:16 AM, loial <jldunn2000@gmail.com> wrote:
>> On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote:
>>> On Feb 20, 2015 7:46 AM, "loial" <jldun...@gmail.com> 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?
>>>
>>> https://docs.python.org/3/using/windows.html#launcher
>>>
>>> Note that while the launcher can be used with any version of Python, it is only packaged with 3.3+.
>>
>> Vesrion is 2.6
>
> You can install multiple versions of Python on the same system without
> conflict. If you install Python 3.4 also, then you'll have the
> launcher. I don't know if there's an easy way to install just the
> launcher.

https://bitbucket.org/vinay.sajip/pylauncher/overview

has the standalone launcher (msi installers are in the downloads section).

[toc] | [prev] | [next] | [standalone]


#85978

Fromwxjmfauth@gmail.com
Date2015-02-20 07:20 -0800
Message-ID<0ffccc89-970d-4504-a6d7-d3c4d5788c58@googlegroups.com>
In reply to#85973
Le vendredi 20 février 2015 15:43:38 UTC+1, loial a écrit :
> On Linux we use 
> #!/usr/bin/env python
> 

Which one of theese?

>>> 'abcßdef'.upper()
'ABCßDEF'

>>> 'abcßdef'.upper()
'ABCSSDEF'

>>> 'abcßdef'.upper()
'ABC\xe1DEF'
>>>

[toc] | [prev] | [next] | [standalone]


#86024 — Re: Python path on windows

FromGisle Vanem <gvanem@yahoo.no>
Date2015-02-21 12:05 +0100
SubjectRe: Python path on windows
Message-ID<mailman.18954.1424516851.18130.python-list@python.org>
In reply to#85973
Dave Angel wrote:

> Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use.

py.exe? Do you mean python.exe?

Is there a way to make python.exe ignore all Shebang lines
in all scripts? I had many generated .py-files with:
   #!g:\ProgramFiler\Python27\python.EXE

After transferring my Python tree to a new Win-8.1 PC, my Python
tree was installed under "f:\ProgramFiler\" and my CD-ROM on "g:\"

This caused those scripts to access my CD-ROM or pop-up a Win-GUI
error dialogue if no CD-ROM was in the drive. Irritating.


-- 
--gv

[toc] | [prev] | [next] | [standalone]


#86027 — Re: Python path on windows

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-02-21 12:36 +0000
SubjectRe: Python path on windows
Message-ID<mailman.18956.1424522199.18130.python-list@python.org>
In reply to#85973
On 21/02/2015 11:05, Gisle Vanem wrote:
> Dave Angel wrote:
>
>> Finally, when py.exe starts, it reads that first (shebang) line, and
>> decides which python interpreter to actually use.
>
> py.exe? Do you mean python.exe?
>

py.exe or pyw.exe come with the Python launcher on Windows and work out 
which version of the interpreter to use.

https://www.python.org/dev/peps/pep-0397/
https://docs.python.org/3/using/windows.html#python-launcher-for-windows

I think it was first installed with Python 3.3.  It's available here 
https://bitbucket.org/vinay.sajip/pylauncher if you're on an older version.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#86036 — Re: Python path on windows

FromDave Angel <davea@davea.name>
Date2015-02-21 09:10 -0500
SubjectRe: Python path on windows
Message-ID<mailman.18963.1424527851.18130.python-list@python.org>
In reply to#85973
On 02/21/2015 06:05 AM, Gisle Vanem wrote:
> Dave Angel wrote:
>
>> Finally, when py.exe starts, it reads that first (shebang) line, and
>> decides which python interpreter to actually use.
>
> py.exe? Do you mean python.exe?

Reread my post, or read Mark's reply to yours.  The job of py.exe or 
pyw.exe is to examine the shebang line and then exec the appropriate 
python.exe

>
> Is there a way to make python.exe ignore all Shebang lines
> in all scripts? I had many generated .py-files with:
>    #!g:\ProgramFiler\Python27\python.EXE

That's what symlinks are for, on Unix-like systems.  Somewhere I read 
that Windows has had them for a little while now.  Those generated files 
should have pointed to a symlink on your system drive, rather than 
pointing directly to drive G:

But you could always write your own py.exe, which interprets the shebang 
differently.

Or run python.exe yourself, which as far as I know, pays no attention to 
shebang lines.

>
> After transferring my Python tree to a new Win-8.1 PC, my Python
> tree was installed under "f:\ProgramFiler\" and my CD-ROM on "g:\"
>
> This caused those scripts to access my CD-ROM or pop-up a Win-GUI
> error dialogue if no CD-ROM was in the drive. Irritating.
>
>


-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#86041 — Re: Python path on windows

FromChris Angelico <rosuav@gmail.com>
Date2015-02-22 01:40 +1100
SubjectRe: Python path on windows
Message-ID<mailman.18968.1424529632.18130.python-list@python.org>
In reply to#85973
On Sun, Feb 22, 2015 at 1:10 AM, Dave Angel <davea@davea.name> wrote:
> But you could always write your own py.exe, which interprets the shebang
> differently.
>
> Or run python.exe yourself, which as far as I know, pays no attention to
> shebang lines.

Or, my preferred solution: Fix the shebangs :) It's usually not hard
to put together a script that zips through your hard drive and fixed
them... or else you just fix 'em when you notice 'em, which means your
shebangs become a kind of historic marker. I used to have drive
letters all over my code, and I could track a program's history
through them: this used to be on D:, then it moved to E:, etc.
Discovering something that still said "D:\eddie" was like digging up a
Second World War bullet casing.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web