How to Set Default Executable Python from Multiple Python available in Microsoft Windows

Posted on

Introduction

As in the title of this article, it will contain a specific subject about how to set default executable python in Microsoft Windows. The background for writing this article is because of the existence of multiple python program. Actually, this is a result from another step. That step is defining a new executable python path. For a reference, it exist in an article with the title of ‘How to Add Executable Python Path in Microsoft Windows 11’ in this link. The following is the execution of those multiple python program :

Microsoft Windows [Version 10.0.22000.675]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Personal>where python
C:\Program Files\Inkscape\bin\python.exe
C:\Users\Personal\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\Personal\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\Personal>

As it exist in the above output command execution, there are several location where the executable python exist. There is an executable python exist in three different places. So, in order to check which python is currently active for the default execution in the command prompt, just execute the following command :

C:\Users\Personal>python -V
Python 3.9.10
C:\Users\Personal>

So, after executing the above command for checking the version, there is one simple question occurs after. The question is where is the exact location of that python ?. In order to confirm it further, just check it one by one from the Command Prompt as follows :

Microsoft Windows [Version 10.0.22000.675]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Personel>
  1. The following is the sequence for checking each one of those manually starting from the upper row :

    C:\Users\Personel>cd \
    C:\>cd "Program Files"
    C:\Program Files>cd Inkscape
    C:\Program Files\Inkscape>cd bin
    C:\Program Files\Inkscape\bin>python.exe -V
    Python 3.9.10
    C:\Program Files\Inkscape\bin>
    

    Apparently, the first line which is the ‘C:\Program Files\Inkscape\bin\python.exe’ has an executable python with the version of ‘3.9.10’.

  2. Following after is the second row which exist below :

    C:\Program Files\Inkscape\bin>cd C:\Users\Personal\AppData\Local\Programs\Python\Python310
    C:\Users\Personal\AppData\Local\Programs\Python\Python310>python.exe -V
    Python 3.10.5
    C:\Users\Personal\AppData\Local\Programs\Python\Python310>
    

    The second row where the python exist in ‘C:\Users\Personal\AppData\Local\Programs\Python\Python310\python.exe’ has the version of ‘3.10.5’.

  3. And in the third row which is the bottom row is in the following execution :

    C:\Users\Personal\AppData\Local\Programs\Python\Python310>cd C:\Users\Personal\AppData\Local\Microsoft\WindowsApps
    C:\Users\Personal\AppData\Local\Microsoft\WindowsApps>python.exe -V
    Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
    C:\Users\Personal\AppData\Local\Microsoft\WindowsApps>
    

    The last one above does not count as a proper executable python path since it cannot find where the Python is.

So, as a conclusion, since the currently active python’s version is 3.9.10 which is exactly the same one with the executable python path available in the first row, it means the upper row or the top in the list will be the default one.

How to Set Default Executable Python from Multiple Python available in Microsoft Windows

In this part, as it exist in the conclusion in the previous part, just switch the order of the list to change the default executable python. It is very easy to do that. In this case, just switch the order of the entry list in the environment variable definition. Below are the steps for defining it :

  1. First of all, just search the environment variables’s settings as in the following image :

    How to Set Default Executable Python from Multiple Python available in Microsoft Windows

    So, execute the edit environment variables by clicking the ‘Edit the system environment variables’ which is actually exist in the Control panel.

  2. Soon after, there will be a environment variable window appear as in the following image :

    How to Set Default Executable Python from Multiple Python available in Microsoft Windows
  3. Next, click the Environment Variables button in the Advanced Tab as appear in the image exist in the above step. After that, there will be another window presenting list of environment variables as in the following image :

    How to Set Default Executable Python from Multiple Python available in Microsoft Windows
  4. Select the environment variables with the name of ‘Path’ in the System Variables as in the image follows :

    How to Set Default Executable Python from Multiple Python available in Microsoft Windows

    In the window above, click the Edit… button after selecting the ‘Path’ environment variable.

  5. Another window will appear displaying the value of the ‘Path’ environment variable as in the following image :

    How to Set Default Executable Python from Multiple Python available in Microsoft Windows
  6. So, select the last row which is the chosen executable python as a default executable python as in the image above. After that, just click the Move Up button to move the selected row to the appropriate place. Actually, in order to change the default executable python path, just move it slightly above as follows :

    How to Set Default Executable Python from Multiple Python available in Microsoft Windows

    Last but not least, just click the OK button to close the window for editing the ‘Path’ environment variable. After that, just click the OK button once more in the Environment Variables window to close it.

How to Test Chose Executable Python from Multiple Python available in Microsoft Windows

In this part, it only focus after to check and test. It is to prove that the executable python is no longer the same after editing the ‘Path’ environment variable to move up the chosen executable python path in the list definition. So, the following is the steps to achieve that :

  1. First of all, just run the Command Prompt.

  2. Following after, just type the command below to check the list order of the executable python :

    C:\Users\Personal>where python
    C:\Users\Personal\AppData\Local\Programs\Python\Python310\python.exe
    C:\Program Files\Inkscape\bin\python.exe
    C:\Users\Personal\AppData\Local\Microsoft\WindowsApps\python.exe
    C:\Users\Personal>
    

    As it exist in the above output command, the order of the list is now it is not the same anymore. The top or the upper list is now in ‘C:\Users\Personal\AppData\Local\Programs\Python\Python310\python.exe’ instead of ‘C:\Program Files\Inkscape\bin\python.exe’.

  3. Next, check the version of the python by typing the following command :

    C:\Users\Personal>python -V
    Python 3.10.5
    C:\Users\Personal>

    As in the output of the above command for checking the python version, currently it is already a different one. The previous version is ‘3.9.10’ and the current one is ‘3.10.5’.

Leave a Reply