THE FOUNDER’S GUIDE:

How to Install and Manage Multiple Python Versions in WSL2

The condensed tutorial with copy and paste code and screenshots

“The expanded version of this article uses concise explanations to help you learn what’s happening 💡”

Open PowerShell:

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Click “Run as Administrator”

Open WSL2:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
wsl

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python --version

Check the Executable File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
which python

Open the Home Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
cd $HOME

Install Git:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt-get install --yes git

Clone the Pyenv Repository:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Open the Bash Configuration File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
notepad ~/.bashrc

Edit the Bash Configuration File:

  1. Copy the code from below these instructions
  2. Paste the code into Notepad
  3. Click the “File” menu
  4. 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 -)"
fi

Restart WSL2:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
exec $SHELL

Update the Source List and Source List Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt-get update --yes

Install the Pyenv Dependencies:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. 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:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
pyenv install --list

Install Python:

  1. Find the version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
  5. Repeat
Python 3.5:
pyenv install 3.5.4
Python 3.6:
pyenv install 3.6.8
Python 3.7:
pyenv install 3.7.9
Python 3.8:
pyenv install 3.8.6
Python 3.9:
pyenv install 3.9.0

Set the Default Version for the Computer:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
pyenv global 3.8.6

Create the Temporary Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
mkdir temporary

Open the Temporary Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
cd temporary

Set the Default Version for the Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
pyenv local 3.6.8

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python --version

Open the Parent Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
cd ..

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python --version

Open the Temporary Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
cd temporary

Create the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python -m venv venv36

Activate the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
source ./venv36/bin/activate

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python --version

Check the Executable File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
which python

Deactivate the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. 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 Learning
WSL2:
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 Learning
Mac:
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

From: Non-Technical | To: Technical | Writes: To Make It Easier For Everyone | Topics: #Setup #Basics #AI #MachineLearning #DeepLearning #Repositories

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store