CMD opens window store when I type python

João Vitor Degrandi picture João Vitor Degrandi · Nov 7, 2019 · Viewed 49.6k times · Source

Today when I tryed to run a simple code on Sublime Text 3, the following message appeard:

Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640

And when I type Python in CMD, it opens the Windows Store for me to download Python 3.7. This problem started today for no good reason, I didn't change or downloaded anything about Python and already tryied reinstalling Python, and the Path is correct.

Answer

betafractal picture betafractal · Nov 8, 2019

Two solutions:

  1. As ChipJust said it may be possible to use "py" as the new alias for python in Windows10.

  2. As explained here https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/, use the search bar to find "Manage App Execution Aliases". There should be two aliases for python, see image, unselect them, which will allow the usual python aliases "python" and "python3"

This works because Microsoft created the %USERPROFILE%\AppData\Local\Microsoft\WindowsApps dir for the Execution Alias system. There is a empty or "fake" *.exe in that dir because that essentially is the alias. What is really cool about MS's implementation, is that disabling the alias deletes the empty *.exe. Thus when you type the alias python, or spotify, etc, in cmd, Windows searches for the alias but won't find the empty *.exe anymore, and instead keeps searching the PATH until it finds the *.exe at the installed location if on the PATH. It is beneficial because you don't have to keep reodering the path for every new program you install that also has an alias, and based on the blog post by MS, it seems like this is the intended use.