Does windows edit .py file shebangs?

Eryk Sun eryksun at gmail.com
Fri Jan 1 12:03:07 EST 2021


On 1/1/21, Barry Scott <barry at barrys-emacs.org> wrote:
> I found python scripts have had their shebang lines edited behind my back.
>
> The shebang line I'm seeing is:
>
>     #!C:\Users\barry\AppData\Local\Microsoft\WindowsApps\python3.EXE
>
> Is this Microsoft being "helpful"?
> Does anyone know what I will have done to best with this "help"?
>
> What do I need to do to prevent this happening?

Shebang lines may be localized to the current interpreter when
installing a package. Otherwise I don't know what's causing that.

Regarding Windows, the system doesn't support shebang lines in any
way. Python's installer associates .py files with the py.exe launcher,
which looks for a shebang line in a script in order to determine which
executable to run. It supports shebangs with fully-qualified Windows
paths, as well as virtual commands for registered installations, such
as "python", "python3", "python3.9-32", "/usr/bin/python3", and
"/usr/bin/env python".


More information about the Python-list mailing list