Multiple Versions on Windows
How to manage multiple Python versions on a Windows system.
Using Pyenv for Windows
We can manage multiple Python versions on a system using pyenv for Windows , which brings the same capabilities than on an Unix system. See Multiple versions on macOS .
List the available Python installations
Install a Python version
Set the global Python version
Set the Python version only for the current shell
Deprecated
The following method is deprecated in favor of pyenv .
How-to
We can define some batch scripts in a given directory. In the case we're using
Cloud VFX Server
, we can rely on
$ENVIRONMENT_ROOT
(which expand to
C:\Users\valen\OneDrive\.config\environment
in my case).
In
$ENVIRONMENT_ROOT
, create a
python
folder:
C:\Users\valen\OneDrive\.config\environment\python
.
You can now create a batch script for each version of python you want to use in this folder:
python39.bat
@ECHO OFF
setlocal
set "PYTHONHOME=%LOCALAPPDATA%\programs\python\python39"
set "PYTHONPATH=%PYTHONHOME%\lib;%PYTHONPATH%"
"%PYTHONHOME%\python.exe" %*
endlocal
Finally, edit your
$PATH
environment variable, adding as a
first entry
the
%ENVIRONMENT_ROOT%\python
folder, so the batch files are accessible inside a terminal.
Pip
You can now use
pip
using this method, by typing: