I have installed Python 3.11 from Windows Store. I used to have Python 3.10 also installed from Windows store, but I changed the environment variables and could not use it from the terminal anymore. Therefore I decided to uninstall it and install the latest version, hoping that it would be added to PATH automatically, just like it happened the first time I installed the previous version.
The reason why I am installing it from Windows store is because that is the only interpreter that VSCode is able to find (I have tried accessing another Python interpreter and VSCode would just not allow me).
At the moment, this Python interpreter has the following route
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1008.0_x64__qbz5n2kfra8p0\python3.11.exe
I have copy-pasted it to my Path and still can't run python on a terminal. What I mean by this is that if I type "python", the command is not recognized.
This is the complete directory in which the .exe file is, in case it is useful
EDIT I also have the following route
C:\Users\Usuario\AppData\Local\Programs\Python\Python311
That contains the following
I have a vague memory of the Scripts folder being in the Path before, but adding it does not solve the issue either. I have also added the above route (where the Scripts folder is) and still does not work. What can I do to be able to run python from terminal?
This OP's question seems to be closest to the problem I had this morning which I have now solved, so I'm sharing how I set my default python from a number of different versions I had installed from the Windows Store.
In my case I wanted to set a PYTHON environment variable to the actual path of the EXE installed form the store. The path was long and I seemed to have to run my command prompt with elevated privileges to even access it.
Rather than "fix" that, the solution below seems to be how best to do it in Windows 10, and I assume Windows 11:
Manage App Execution Aliases
An App Execution Alias is like a shortcut to an application. These are configurable in the Windows Settings (search for "Manage App Execution Aliases") and can be used to specify which version of python is called when you run python
, python3
, etc. from the command line.
When you open this part of the Windows Settings app, you should see a list of packages. Each entry in the list will be in the form:
|##| Package Name < > On/Off
|##| alias
for example:
|##| Python 3.10 <_*> On
|##| python.exe
It takes a moment to work out what is going on, but you'll realize that you can toggle the on/off switch on the right hand side to decide which package is called for a given alias.
In my case I wanted to ensure that Python 3.10 was the default one (for PyTorch compatibility) so I made sure that the following package/alias mappings were enabled:
As you enable each of these, it will automatically unset any other package that was set to use that alias.
Using the alias
In my testing the alias appeared to work correctly:
C:\> python3.10.exe --version
Python 3.10.11
C:\> python3 --version
Python 3.10.11
C:\> python --version
Python 3.10.11
With the alias working, I didn't need to modify the PATH at all.
Using other python versions
If you have other python packages installed, you can still keep aliases for those versions, e.g.:
If you want to run a specific version of python that you have installed via the Windows Store, you just include the alias with the correct version number, e.g. python3.8
and this will map to the executable from that package.
I finally solved it by looking at another device where I had a similar configuration. I needed to add
C:\Users\Usuario\AppData\Local\Microsoft\WindowsApps
and
C:\Users\Usuario\AppData\Local\Microsoft\WindowsApps\python3.11.exe
to the path. That worked. Still don't know why Windows Store didn't add them automatically this time tho.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With