Am 15.01.2024 um 00:46 schrieb Mike Dewhirst via Python-list:
In Windows the provided methods for running complex command lines are either a 
batch file or a shortcut.Someone very kindly pointed out to me in this thread 
that there is a PEP for py.exe. I don't use py.exe originally because I didn't 
trust it believing it was a new-fangled Microsoft trick. I did read that PEP 
but it has no relevance for my mixed Windows/Linux environments. On reflection 
I now believe I won't use py.exe because it introduces an unnecessary layer of 
indirection.The  bottom line is that you still need to know which Python a 
particular set of circumstances demands and if you use py.exe you then need to 
also understand how it chooses and how it interprets shebang lines written for 
your Linux environment. And if that isn't your situation I have jumped to the 
wrong conclusion.I have found no problem in Windows when I use shebang lines in 
scripts intended for execution in both Linux and Windows. They are ignored 
unless you use py.exe.My advice is to give up py.exe unless your use case 
mandates shebang lines in Windows.M--(Unsigned mail from my phone)

First and foremost I want to understand why I'm seeing this:

- Python scripts with "/usr/bin/env python3" as shebang line work as expected on a computer with Windows 10 and Python 3.11.5. They have worked for years on this machine, using either the latest Python or one version before (depending on availability of some packages). There is a virtual machine with ArchLinux on the same machine and some of the scripts are copies from that.

- I've got a second computer with Windows 11 and I installed Python 3.12.1 on it. After copying some scripts from my first computer I found that I couldn't start them: not by entering the script name in a console, not using py.exe, not double clicking in the explorer. Entering <full_path_to_python.exe>\python <scriptname> probably worked - I think I tried that too, but I'm not really sure, because that's really not practical.

In the Python documentation for versions 3.11 and 3.12 I found no differences regarding py.exe and shebang lines.

Then I removed the "/env" from the shebang lines and could start the scripts from the second computer. That certainly is a solution, but why???

Sibylle



--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to