Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Store not adding Python to PATH

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

enter image description here

EDIT I also have the following route

C:\Users\Usuario\AppData\Local\Programs\Python\Python311

That contains the following enter image description here

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?

like image 815
Javi Avatar asked Sep 02 '25 10:09

Javi


2 Answers

Setting default python from versions installed from Windows Store

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:

  • IDLE (Python 3.10) -> idle.exe
  • IDLE (Python 3.10) -> idle3.exe
  • IDLE (Python 3.10) -> idle3.10.exe
  • Python 3.10 -> python.exe
  • Python 3.10 -> python3.exe
  • Python 3.10 -> python3.10.exe
  • Python 3.10 (Windowed) -> pythonw.exe
  • Python 3.10 (Windowed) -> pythonw3.exe
  • Python 3.10 (Windowed) -> pythonw3.10.exe

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.:

  • Python 3.8 -> python3.8.exe
  • Python 3.10 -> python3.10.exe

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.

like image 192
Charlie Joynt Avatar answered Sep 04 '25 05:09

Charlie Joynt


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.

like image 22
Javi Avatar answered Sep 04 '25 06:09

Javi