Skip to content
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

Start.ps1 still falsely concludes Python 3 is available, despite being already installed. #16

Closed
andrewtoups opened this issue Sep 1, 2023 · 3 comments

Comments

@andrewtoups
Copy link

First of all thanks for making this software, it's proving to be a life-saver for me right now!

This issue seems similar to #2, although my situation is a little different.

I do have Python 3 installed, but I still get the Microsoft Store redirect when I try to run a python script from powershell. After doing some digging, it seems this was the culprit:

I think we have this problem when installing Python because in a new Windows installation the aliases are in the ON position as in image below. When turned on, Windows puts an empty or fake file named python.exe and python3.exe in the directory named %USERPROFILE%\AppData\Local\Microsoft\WindowsApps. This is the alias.

UCwkU

Then Microsoft put that directory at the top of the list in the "Path" environment variables.

iTeHL

When you enter "python" in cmd, it searches the directories listed in your "Path" environment variables page from top to bottom. So if you installed Python after a new Windows 10 install then get redirected to the Windows Store, it's because there are two python.exe's: The alias in the App Execution Alias page, and the real one wherever you installed Python. But cmd finds the App execution, alias python.exe, first because that directory is at the top of the Path.

Obnoxious of Windows to do this, but it's easy enough to fix once you see what's going on. I don't know if there's an easy programmatic way to handle this in-script, but maybe at least either alert the user to remove their aliases if the script doesn't actually run, or just move to the next fallback? Or even just adding a note in the docs about this potential pitfall.

(Someone suggested a programmatic solution to this issue for use in scripts, though I'm not sure if directly messing with the user's aliases like this is the best idea:)

Remove-Item $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\python*.exe

@HimbeersaftLP
Copy link
Owner

I wonder if there is an easy way to check if python actually runs that would not open the Microsoft Store in case the alias has higher priority (or Python is not installed)?

@HimbeersaftLP
Copy link
Owner

I implemented a fix in the commit 77620eb

@HimbeersaftLP
Copy link
Owner

Thank you for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants