Link Search Menu Expand Document

What if I have multiple Python versions?

You can have multiple simultaneous Python versions installed on Windows, but you will need to provide a separate way of referring to each. To do this we need to make some changes to our environment variables in Windows and create some shortcuts to our Python interpreters.

If you do not care about having multiple Python versions, just uninstall the version that is not Python 3.9.

Environement Variable Setup

  1. Open the environment variable manager in windows
    • Press the windows key, type environment into the search box and you should see a result for environment variables
  2. Hit enter to open the application
  3. You should see a window that looks like the one pictured on the left of the image below Environement Variable Manager
  4. Click the Path Varible in the top section and click the edit button
  5. A new window should appear that looks like the one pictured on the right of the image above
  6. Make sure that each Python version is present in this list
    • In my image you can see that my accout has two paths, one for version 3.9 and another for 3.10
  7. If these are NOT present you will need to use the browse button to find the Python folders and add them. The Python folders will be named similarly to mine, but the path will differ.
  8. Once you have confirmed or added the Paths to your Python installations, hit okay to close the Edit Environment Variable window
  9. In the main environment variables window, you will need to also change the PATHEXT variable
  10. Click the PATHEXT variable in the lower window and click edit
  11. Add ;.LNK to the end of the list of file extensions and click OK.
  12. Click OK to close the main Window

Python Shortcuts

  1. We now need to locate the installation folder for each Python Version
    • You can Google to find the potential paths, or use the information in the Environment Variable manager used in the previous section
  2. Once you find the folder, locate the file named python
  3. Right click the python file and select “Create Shortcut” from the menu
  4. Name the shortcut python[version]
    • For example, python 3.8 would have a shortcut named python38 and python 3.10 would need a shortcut named python310
  5. Repeat this process for all your Python installations

Running Python

Now that you have shortcuts for all the different python versions, you can use each one separately by using the command python[version] in your Visual Studio Code terminal. For example, to run a program named test.py with python 3.10 the command would be python310 test.py to do the same program with python 3.8 the command would be python38 test.py