3

The community-accepted solution for including a shebang line for Python seems to be to use #!/usr/bin/env python3. However, when I install Python 3 using the winget package (i.e. winget install --id Python.Python.3.11), and then attempt to run a script with the shebang (i.e. py some_script_with_shebang.py), I get an error:

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings

> Manage App Execution Aliases.

Through investigation, I found that I can install the msstore package to resolve this (winget install --id 9NRWMJP3717K, and where python3 returns %LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe). However, I don't know why I need to install the msstore version (with the opaque ID), rather than the winget package (with the transparent ID).

1 Answers1

-2

Could it be that you didn't re-open your command prompt after winget install --id Python.Python.3.11? In that case, the new python wouldn't have been on your PATH yet. Normally, winget does place Python on the PATH, but it only takes effect in new command prompt windows. This is discussed for example in https://winget.pro/winget-install-python/.