THE FOUNDER’S GUIDE:
How to Install and Manage Multiple Python Versions in WSL2
The expanded tutorial with concise explanations and screenshots

“The condensed version of this article uses copy and paste code to help you get the outcome ASAP ⚡”
Open PowerShell:
PowerShell is a command-line shell and object-oriented scripting language that’s used to automate administrative tasks and configure system settings. It can be used to automate practically anything in the operating system. It also replaced Command Prompt as the default system shell for Windows 10.
- Press “⊞ Windows”
- Enter “PowerShell” into the search bar
- Click “Run as Administrator”

Open WSL2:
Windows Subsystem for Linux 2 (WSL2) is a Windows 10 feature that allows users run Linux on Windows without using dual-boot or a virtual machine. It has full access to both filesystems, GPU support, and network application support. It also provides access to thousands of Linux command-line tools.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
wsl

Check the Default Version:
The Version (V) option is used to check which version of Python is currently selected as the default version. It consists of three numbers separated by periods that represent the major, minor, and micro version number. It also displays an error message if Python isn’t already installed on the computer.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
python --version

Check the Executable File:
The Which command is used to identify the location of the executable file for the specified command name. It searches for the executable file in the list of directories from the PATH environment variable. It also displays the absolute path of the executable file if it exists in the one of the directories.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
which python

Open the Home Directory:
The Change Directory (cd) command is used to change the current working directory to the specified directory. It can navigate to absolute and relative paths that start from the root and current working directory, respectively. It can also navigate to paths stored in variables and environment variables.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
cd $HOME

Install Git:
Git is a program that’s used to track changes that are made to the source code over time. It can handle projects of all sizes and allows multiple teams and people to make changes to the same repository. It can also restore the source code to a previous version from the entire history of the repository.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
sudo apt-get install --yes git

Clone the Pyenv Repository:
Pyenv is a program that’s used for Python version management on macOS and Linux. It can install multiple Python versions, specify the version that’s used system-wide, and specify the version that’s used in specific directories. It can also create and manage virtual environments using specific versions.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Open the Bash Configuration File:
The Shell Configuration File is a script that’s automatically executed when a shell is opened by the user. It contains code that’s used to change the look of the shell, run scripts and commands, create aliases, and load environment variables. It also creates a separate configuration file for the different shells.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
notepad ~/.bashrc

Edit the Bash Configuration File:
Bourne Again Shell (Bash) is a command-line shell and scripting language that’s used to automate administrative tasks and configure system settings. It can be used to automate practically anything in the operating system. It has also been the default shell for most Linux-based operating systems.
- Copy the code from below these instructions
- Paste the code into Notepad
- Click the “File” menu
- Click “Save”
# Pyenv environment variables
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"# Pyenv initialization
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init --path)"
fi

Restart WSL2:
The Exec (e) command is used to execute the specified command that’s provided as an argument. It destroys the current process and replaces it with the specified command without creating a new process. It can also restart the shell to reload the configuration file into the environment.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
exec $SHELL

Update the Source List and Source List Directory:
The Update command is used to ensure the list of available packages is up to date. It downloads a package list from the repositories on the system which contains information about new and upgradable packages. It only updates information about the packages and doesn’t actually upgrade the packages.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
sudo apt-get update --yes

Install the Pyenv Dependencies:
The Dependency is an additional binary package that a particular binary package needs to work properly. It can require multiple dependencies to build almost any program that’s distributed by package managers. It also gets downloaded and installed automatically by some package managers.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
sudo apt-get install --yes libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libgdbm-dev lzma lzma-dev tcl-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev wget curl make build-essential python-openssl

View the Python Versions:
The List (l) flag is used to display the Python versions that are available in Pyenv. It includes final versions that are released from Python, Anaconda, PyPy, Jython, and Stackless. This includes all the major, minor, and micro versions but it doesn’t include alpha, beta, or release candidate versions.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
pyenv install --list

Install Python:
Python is an object-oriented language that’s known for its simple syntax, code readability, flexibility, and scalability. It mostly gets used to develop web and software applications. It also has become one of the most popular languages for artificial intelligence, machine learning, and data science.
- Find the version from below these instructions
- Copy the provided command
- Paste the command into PowerShell
- Press “Enter”
- Repeat
Python 3.5:
pyenv install 3.5.4Python 3.6:
pyenv install 3.6.8Python 3.7:
pyenv install 3.7.9Python 3.8:
pyenv install 3.8.6Python 3.9:
pyenv install 3.9.0

Set the Default Version for the Computer:
The Global command is used in Pyenv to specify the default Python version for the entire system. It creates a text file in the Pyenv directory that stores the specified version. This is used by Pyenv to activate the default version but it gets overwritten by the local Pyenv text file and environment variable.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
pyenv global 3.8.6

Create the Temporary Directory:
The Make Directory (mkdir) command is used to create new directories. It can specify one or more relative or absolute paths with the name of the new directories to be created. It can also be used with the “Parents” flag to create parent directories as needed without overwriting a path that already exists.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
mkdir temporary

Open the Temporary Directory:
The Change Directory (cd) command is used to change the current working directory to the specified directory. It can navigate to absolute and relative paths that start from the root and current working directory, respectively. It can also navigate to paths stored in variables and environment variables.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
cd temporary

Set the Default Version for the Directory:
The Local command is used in Pyenv to specify the default Python version for the current directory. It creates a text file in the current directory that stores the specified version. This is automatically detected by Pyenv which activates the Python version in the current directory and subdirectories.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
pyenv local 3.6.8

Check the Default Version:
The Version (V) option is used to check which version of Python is currently selected as the default version. It consists of three numbers separated by periods that represent the major, minor, and micro version number. It also displays an error message if Python isn’t already installed on the computer.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
python --version

Open the Parent Directory:
The Change Directory (cd) command is used to change the current working directory to the specified directory. It can navigate to absolute and relative paths that start from the root and current working directory, respectively. It can also navigate to paths stored in variables and environment variables.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
cd ..

Check the Default Version:
The Version (V) option is used to check which version of Python is currently selected as the default version. It consists of three numbers separated by periods that represent the major, minor, and micro version number. It also displays an error message if Python isn’t already installed on the computer.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
python --version

Open the Temporary Directory:
The Change Directory (cd) command is used to change the current working directory to the specified directory. It can navigate to absolute and relative paths that start from the root and current working directory, respectively. It can also navigate to paths stored in variables and environment variables.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
cd temporary

Create the Virtual Environment:
The Virtual Environment is an isolated Python installation directory that has its own interpreter, site-packages, and scripts. It mostly gets used to prevent version conflicts between dependencies from different projects. It also gets used to meet dependency requirements of different programs from GitHub.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
python -m venv venv36

Activate the Virtual Environment:
The Activate script is used to start the virtual environment. It prepends the virtual environment path to the PATH environment variable which sets the new Python interpreter and package manager as the default version. It also sets packages to install in the virtual environment installation directory.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
source ./venv36/bin/activate

Check the Default Version:
The Version (V) option is used to check which version of Python is currently selected as the default version. It consists of three numbers separated by periods that represent the major, minor, and micro version number. It also displays an error message if Python isn’t already installed on the computer.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
python --version

Check the Executable File:
The Which command is used to identify the location of the executable file for the specified command name. It searches for the executable file in the list of directories from the PATH environment variable. It also displays the absolute path of the executable file if it exists in the one of the directories.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
which python

Deactivate the Virtual Environment:
The Deactivate command is used to stop the virtual environment. It removes the virtual environment path from the PATH environment variable which sets the last Python interpreter and package manager as the default version. It also sets packages to install in the system Python installation directory.
- Copy the command from below these instructions
- Paste the command into PowerShell
- Press “Enter”
deactivate

“Hopefully, this article helped you get the 👯♀️🏆👯♀️, remember to subscribe to get more content 🏅”
Next Steps:
This article is part of a mini-series that helps readers set up everything they need to start learning about artificial intelligence, machine learning, deep learning, and or data science. It includes articles that contain instructions with copy and paste code and screenshots to help readers get the outcome as soon as possible. It also includes articles that contain instructions with explanations and screenshots to help readers learn about what’s happening.
Linux:
01. Install and Manage Multiple Python Versions
02. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
03. Install the Jupyter Notebook Server
04. Install Virtual Environments in Jupyter Notebook
05. Install the Python Environment for AI and Machine LearningWSL2:
01. Install Windows Subsystem for Linux 2
02. Install and Manage Multiple Python Versions
03. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
04. Install the Jupyter Notebook Server
05. Install Virtual Environments in Jupyter Notebook
06. Install the Python Environment for AI and Machine Learning
07. Install Ubuntu Desktop With a Graphical User Interface (Bonus)Windows 10:
01. Install and Manage Multiple Python Versions
02. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
03. Install the Jupyter Notebook Server
04. Install Virtual Environments in Jupyter Notebook
05. Install the Python Environment for AI and Machine LearningMac:
01. Install and Manage Multiple Python Versions
02. Install the Jupyter Notebook Server
03. Install Virtual Environments in Jupyter Notebook
04. Install the Python Environment for AI and Machine Learning
Glossary:
The Shell is an interpreter that presents the command-line interface to users and allows them to interact with the kernel. It lets them control the system using commands entered from a keyboard. It also translates the commands from the programming language into the machine language for the kernel.
[Return]
The Interpreter is a program that reads through instructions that are written in human readable programming languages and executes the instructions from top to bottom. It translates each instruction to a machine language the hardware can understand, executes it, and proceeds to the next instruction.
[Return]
The Command-Line Interface (CLI) is a program that accepts text input from the user to run commands on the operating system. It lets them configure the system, install software, and access features that aren’t available in the graphical user interface. It also gets referred to as the terminal or console.
[Return]
The Kernel is the program at the heart of the operating system that controls everything in the computer. It facilitates the memory management, process management, disk management, and task management. It also facilitates communication between the programs and hardware in machine language.
[Return]
The Major version is a number that represents an update that introduces significant changes to a program. It can add different architecture, features, and functionality that’s incompatible with previous versions. This usually causes programs that were built with a previous version to stop working.
[Return]
The Minor version is a number that represents an update that introduces moderate changes to a program. It can add small features and functionality that’s compatible with the latest major update. This usually doesn’t cause problems with programs that were built with the previous minor updates.
[Return]
The Micro version is a number that represents an update that introduces very modest changes to a program. It can add bug fixes and performance enhancements that are compatible with the previous updates. This doesn’t cause problems with programs that were built with the previous updates.
[Return]
The PATH is an environment variable that contains the list of directories the computer uses to find executable files. It looks for the requested executable file in each directory on the list from top to bottom. It also stops searching once it finds a matching executable file and runs the program or command.
[Return]
The Variable is the container that’s used to store different types of values. It can assign or update a value by placing an equals sign between the specified variable name and value without a space around it. It can also reference the stored value by placing a dollar sign in front of the existing variable name.
[Return]
The Environment Variable is a variable that’s automatically created and maintained by the computer. It helps the system know where to install files, find programs, and check for user and system settings. It can also be used by graphical and command-line programs from anywhere on the computer.
[Return]
The Clone command is used in Git to download the specified repository from GitHub. It copies all the files, subdirectories, branches, and commits for the entire history of the repository. It can also be combined with the recursive flag to copy the submodules the repository uses as dependencies.
[Return]
The Submodule is a repository that’s nested inside of a different repository as its subdirectory. It contains a copy of all the files for a specific version of the repository at a particular point in time. It also contains a copy of all the submodules within the repository that are considered its dependencies.
[Return]