-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version numbers not supported for shebang line virtual command /usr/bin/env python on windows #119070
Comments
It looks like it decided to launch the launcher stub rather than a regular Python install, which probably means you haven't got the latest version of the launcher (which will avoid doing this). Disabling the stub from Settings > Manage App Execution Aliases should work, as then the |
In the original implementation of the launcher, "python*" commands in "/usr/bin/env" shebangs were special cased to only search registered Python installations. The new implementation of the launcher always searches Generally that's the right behavior, but it does need to skip Microsoft's generic "python*" app links that run "Microsoft.DesktopAppInstaller". This was fixed back in February for Python 3.11.8+ and 3.12.2+. In PowerShell, you can check the version of the launcher using |
Update: this problem no longer occurs on my machine (i.e. it works as the docs described). However I'm confused as to why, since I didn't disable the stub as @zooba suggests, and the launcher version is 3.12.1. All I've done since posting earlier is clone the Python repo and install Visual Studio (I was intending to implement the doc change). It's a mystery. Thanks both for your comments - I'm happy for this issue to be closed now. |
There is no "python3.12" appexec link for the app installer. Microsoft only creates links by default for "python.exe" and "python3.exe". The reason it's finding "python3.exe" is a bug in the launcher's |
Not us:
I could imagine SearchPathW doing this though, but we should have already added My guess is that it's working now with |
I just stepped through the code in the debugger before writing that post. It's a bug in the launcher. The contents of |
Okay, yeah, that's a bug. That means the Have I ever mentioned how much I wish we didn't try to support these shebang templates 🙃 |
… extension (pythonGH-119426) (cherry picked from commit df93f5d) Co-authored-by: Steve Dower <steve.dower@python.org>
|
On it. We should ignore the exit code for this test - there's a single debug message we're looking for. |
…se non-installed version
See #119846 |
…se non-installed version (pythonGH-119846) (cherry picked from commit 5c48eb0) Co-authored-by: Steve Dower <steve.dower@python.org>
…se non-installed version (pythonGH-119846) (cherry picked from commit 5c48eb0) Co-authored-by: Steve Dower <steve.dower@python.org>
Thanks for the fix! |
…se non-installed version (pythonGH-119846)
…se non-installed version (pythonGH-119846)
…se non-installed version (pythonGH-119846)
Documentation
In section 4.8.2 of the docs (Shebang Lines), it is stated that: "Any of the above virtual commands can be suffixed with an explicit version (either just the major version, or the major and minor version)."
This sentence refers to the 4 virtual commands: /usr/bin/env, /usr/bin/python, /usr/local/bin/python, python.
This is correct for the last 3 virtual commands (e.g. /usr/bin/python3.12 works), but not for /usr/bin/env.
Specifically, using either the major version (e.g. "/usr/bin/env python3") or the major and minor version (e.g. "/usr/bin/env python3.12") in the shebang line of a .py file, then calling the .py with the windows launcher, results in the following error: "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases."
Simple solution: change the relevant sentence in the docs to exclude /usr/bin/env: "Any of the above virtual commands (apart from
/usr/bin/env
) can be suffixed with an explicit version (either just the major version, or the major and minor version)."Linked PRs
The text was updated successfully, but these errors were encountered: