On 1/14/2024 7:48 AM, Sibylle Koczian via Python-list wrote:
Am 09.01.2024 um 12:36 schrieb Barry Scott via Python-list:
On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list
<python-list@python.org> wrote:
Oh, and the two Windows and Python versions are on two different
computers.
Will remove the "/env" from my shebang lines, even if I don't
understand what's happening.
Thanks for the details.
Only thing I can think of is that "python" may be defaulting to mean
python 2.
If you use "#!/usr/bin/env python3" it may work on both.
No, it doesn't. That's the form I started with. When it didn't work I
thought "python3" might be too old, because Python 2 is dead for so long.
Did you creates a py.ini file to configure py.exe?
See if you have %userappdata%\py.ini on either windows 10 or windows 11.
If so what is its contents?
No to both.
I've tried with and without a py.ini and cannot duplicate what you see.
It really seems strange. Only thing I can think of - and I don't really
believe in that idea: as far as I know in Windows 11 the handling of
PATH has changed. My Python isn't on the path, perhaps that is it. A
shebang line without "/env" doesn't check the path, right?
From what I've read recently, if you have a Python program that starts
with a shebang line with any of four standard unix-like paths, then
Python (not Windows) will look for a version of Python in standard
locations - *NOT* in the shebang line locations:
"To allow shebang lines in Python scripts to be portable between Unix
and Windows, this launcher supports a number of ‘virtual’ commands to
specify which interpreter to use. The supported virtual commands are:
/usr/bin/env
/usr/bin/python
/usr/local/bin/python
python
"
Also -
"The /usr/bin/env form of shebang line has one further special property.
Before looking for installed Python interpreters, this form will search
the executable PATH for a Python executable matching the name provided
as the first argument. This corresponds to the behaviour of the Unix env
program, which performs a PATH search. If an executable matching the
first argument after the env command cannot be found, but the argument
starts with python, it will be handled as described for the other
virtual commands.
"
There are some other complications, too, depending on whether you
specify bare "python" or some specific version. The form with
"/usr/bin/env" is the closest to the unix behavior, in that it searches
the PATH. And you write that your intended version of Python is not on
the path.
IOW, these shebang lines don't work the way you seem to think that they do.
See https://docs.python.org/3/using/windows.html for a more complete
rundown.
--
https://mail.python.org/mailman/listinfo/python-list