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
The main problem here is that the order in the path calls the windows from top to bottom, and that there is python.exe
in %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
which is called first if there are no other python.exe
s in the PATH
above that line.
To ensure that the correct python.exe
is called, add the python installation folder (containing python.exe
) to the PATH, above %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
You can manually add Python to windows path by doing this
Here is how a Python application path looks like:
And this is how a Python Scripts path looks like:
4a. If it doesn't show, press new instead of edit and fill the New User Variable box
This is how my Variable value looks like:
C:\Users\Ron\AppData\Local\Programs\Python\Python37-32;C:\Users\Ron\AppData\Local\Programs\Python\Python37-32\Scripts
That’s it! You just added Python to the Windows Path.
Source: Data To Fish
Just download python from the website and install.
Remember to select Add python to path.
Two solutions:
As ChipJust said it may be possible to use "py" as the new alias for python in Windows10.
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.
If python is already installed, then go to Apps & features from settings, select Python, then select modify. Again select modify and select next
Select next, then this window will appear select add python to environment variable
and click on the install button. then again go to apps & features, click modify and then click repair. Now go to CMD and type python. problem solved.
This is a powershell script that does the magic.
Remove-Item $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\python*.exe