bg

Managing Multiple Python Versions on Windows


Posted on February 25, 2023

After downloading a new python version it's often confusing to call for the specific version from windows command prompt.

Goal

Easy way to call a specific version in a way like: python310 -> Python 3.10 python311 -> Python 3.11 etc

Steps

  1. Have multiple python version downloaded.
  2. Open Windows Powershell as administrator.
  3. Use command cd $HOME\appdata\local\programs\python and then use ls to list python directories like following.

_10
Directory: C:\Users\*******\appdata\local\programs\python
_10
Mode LastWriteTime Length Name
_10
d----- 00/00/0000 00:00 AM Python310
_10
d----- 00/00/0000 00:00 AM Python311

  1. For each Python version use command copy python[version]\python.exe python[version]\python[version].exe For exmaple: Python311 would use copy python311\python.exe python311\python311.exe
  2. Open Environment Variables from System Properties and edit Path.
  3. For each Python version add c:\users\[user]\appdata\local\programs\python\python[version]\scripts\ and c:\users\[user]\appdata\local\programs\python\python[version]\
  4. Set default version by moving them up.
  5. Now python can be called in command prompt using python[version].

© cocdeshijie. All rights reserved.