The Founder’s Guide:
How to Install Virtual Environments in Jupyter Notebook in WSL2
The condensed tutorial with instructions and screenshots
The expanded version of this article explains each step with enough detail to learn what’s happening.
Open Terminal:
- Open the web browser
- Enter the IP address to the Jupyter Notebook server
- Press “Enter”
- Click “New”
- Click “Terminal”
Set the Username Variable:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
username=$(wslvar USERNAME)
Open the Desktop Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
cd /mnt/c/users/$username/desktop/
Clone the Repository:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
git clone --recursive https://github.com/zzh8829/yolov3-tf2.git
Open the YoloV3-Tf2 Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
cd yolov3-tf2
Create the Virtual Environment:
- Find the Python version from below these instructions
- Copy the provided command
- Paste the command into Terminal
- Press “Enter”
Python 3.5:
python3.5 -m venv venv35Python 3.6: <----------
python3.6 -m venv venv36Python 3.7:
python3.7 -m venv venv37Python 3.8:
python3.8 -m venv venv38
Activate the Virtual Environment:
- Find the Python version from below these instructions
- Copy the provided command
- Paste the command into Terminal
- Press “Enter”
Python 3.5:
source venv35/bin/activatePython 3.6: <----------
source venv36/bin/activatePython 3.7:
source venv37/bin/activatePython 3.8:
source venv38/bin/activate
Upgrade Pip:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
pip install --upgrade pip
Open the Requirements File:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
vim requirements.txt
Delete the Requirements:
- Type “:%d” to delete the text
- Press “Enter”
Replace the Requirements:
- Copy the text from below these instructions
- Paste the text into Terminal
- Type “:wq” to save and quit
- Press “Enter”
https://files.pythonhosted.org/packages/be/45/5db2aad27ffeb41273b8019f43447cbbc138e7dc91ba720c6798769dbedb/tensorflow_gpu-2.1.2-cp36-cp36m-manylinux2010_x86_64.whlhttps://files.pythonhosted.org/packages/5e/7e/bd5425f4dacb73367fddc71388a47c1ea570839197c2bcad86478e565186/opencv_python-4.1.1.26-cp36-cp36m-manylinux1_x86_64.whlhttps://files.pythonhosted.org/packages/64/28/0b761b64ecbd63d272ed0e7a6ae6e4402fc37886b59181bfdf274424d693/lxml-4.6.1-cp36-cp36m-manylinux1_x86_64.whlhttps://files.pythonhosted.org/packages/93/3a/96b3dc293aa72443cf9627444c3c221a7ba34bb622e4d8bf1b5d4f2d9d08/tqdm-4.51.0-py2.py3-none-any.whl
Install the Requirements:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
pip install --requirement requirements.txt
Download the Weights:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
wget https://pjreddie.com/media/files/yolov3.weights -O data/yolov3.weights
Convert the Weights:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python convert.py --weights ./data/yolov3.weights --output ./checkpoints/yolov3.tf
Use the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python detect.py --image ./data/meme.jpg
Install IPython Kernel:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
pip install ipykernel
Deactivate the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
deactivate
Install the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
Python 3.5:
sudo venv35/bin/python -m ipykernel install --name yolov3-tf2 --display-name "yolov3-tf2"Python 3.6: <----------
sudo venv36/bin/python -m ipykernel install --name yolov3-tf2 --display-name "yolov3-tf2"Python 3.7:
sudo venv37/bin/python -m ipykernel install --name yolov3-tf2 --display-name "yolov3-tf2"Python 3.8:
sudo venv38/bin/python -m ipykernel install --name yolov3-tf2 --display-name "yolov3-tf2"
Open the YoloV3-Tf2 Directory:
- Reopen Jupyter Notebook
- Click the “Desktop” folder
- Click the “YoloV3-Tf2” folder
Use the Virtual Environment:
- Click “New”
- Click “yolov3-tf2”
Initialize the Detector:
- Copy the code from below these instructions
- Click an empty cell in Jupyter Notebook
- Paste the code into the empty cell
- Press “Shift” + “Enter”
Detect the Image:
- Copy the code from below these instructions
- Click an empty cell in Jupyter Notebook
- Paste the code into the empty cell
- Press “Shift” + “Enter”
List the Installed Virtual Environments:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
jupyter kernelspec list
Remove the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
sudo jupyter kernelspec uninstall yolov3-tf2
Next Steps:
This article is part of a mini-series that helps readers set up everything they need to start using WSL2 for artificial intelligence, machine learning, deep learning, and or data science. It includes articles that contain instructions with copy and paste code and screenshots that help readers get the outcome as soon as possible. It also includes articles that contain instructions with explanations and screenshots that help readers process what’s happening.
01. Install Windows Subsystem for Linux 2 (WSL2)
02. Install the NVIDIA CUDA Driver and Toolkit in WSL2
03. Install Software From Source Code in WSL2
04. Install the Jupyter Notebook Home and Public Server in WSL2
05. Install Virtual Environments in Jupyter Notebook in WSL2
06. Install Programs With a Graphical User Interface in WSL2
07. Install Ubuntu Desktop With a Graphical User Interface in WSL2
Hopefully, this article helped everyone get the prize. If you want to help out then hold the “👋” and click “Follow” to get more content. Thanks for reading!