The Founder’s Guide:

How to Install Virtual Environments in Jupyter Notebook on Mac

The condensed tutorial with copy and paste code and screenshots

David Littlefield
6 min readFeb 13, 2021
Image by Casey Horner

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

Open Terminal:

  1. Open the web browser
  2. Enter the IP address to the Jupyter Notebook server
  3. Press “Return”
  4. Click “New”
  5. Click “Terminal”

Open the Desktop Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
cd $HOME/desktop/

Clone the Repository:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
git clone --recursive https://github.com/zzh8829/yolov3-tf2.git

Open the YoloV3-Tf2 Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
cd yolov3-tf2

Set the Pyenv Version Environment Variable:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
PYENV_VERSION=3.6.8

Create the Virtual Environment:

  1. Find the Python version from below these instructions
  2. Copy the provided command
  3. Paste the command into Terminal
  4. Press “Return”
Python 3.5:
python -m venv venv35
Python 3.6: <----------
python -m venv venv36
Python 3.7:
python -m venv venv37
Python 3.8:
python -m venv venv38

Activate the Virtual Environment:

  1. Find the Python version from below these instructions
  2. Copy the provided command
  3. Paste the command into Terminal
  4. Press “Return”
Python 3.5:
source venv35/bin/activate
Python 3.6: <----------
source venv36/bin/activate
Python 3.7:
source venv37/bin/activate
Python 3.8:
source venv38/bin/activate

Upgrade Pip:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
python -m pip install --upgrade pip

Install the Requirements:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
python -m pip install --requirement requirements.txt

Install Homebrew:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Wget:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
brew install wget

Download the Weights:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
wget https://pjreddie.com/media/files/yolov3.weights -O data/yolov3.weights

Convert the Weights:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
python convert.py --weights ./data/yolov3.weights --output ./checkpoints/yolov3.tf

Use the Repository:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
venv36/bin/python detect.py --image ./data/meme.jpg

Install the IPython Kernel:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
python -m pip install ipykernel

Install the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
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:

  1. Reopen Jupyter Notebook
  2. Click the “Desktop” folder
  3. Click the “YoloV3-Tf2” folder

Use the Virtual Environment:

  1. Refresh the page
  2. Click “New”
  3. Click “yolov3-tf2”

Run the Code Cell:

  1. Copy the code from below these instructions
  2. Click an empty cell in Jupyter Notebook
  3. Paste the code into the empty cell
  4. Press “Shift” + “Enter”

Run the Code Cell:

  1. Copy the code from below these instructions
  2. Click an empty cell in Jupyter Notebook
  3. Paste the code into the empty cell
  4. Press “Shift” + “Enter”

Deactivate the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
deactivate

Unset the Pyenv Version Environment Variable:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
PYENV_VERSION=""

List the Installed Virtual Environments:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
jupyter kernelspec list

Uninstall the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Return”
sudo ~/.pyenv/shims/jupyter kernelspec uninstall yolov3-tf2

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

--

--

David Littlefield
David Littlefield

Written by David Littlefield

From: Non-Technical | To: Technical Founder | Writes: To Make It Easier For Everyone | Topics: #Startups #How-To #Coding #AI #Machine Learning #Deep Learning

No responses yet