The Founder’s Guide:

How to Install the Jupyter Notebook Server in WSL2

The condensed tutorial with copy and paste code and screenshots

David Littlefield
9 min readFeb 23, 2021
Image by Vita Vilcina

“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

Install Jupyter Notebook:

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

Install the WebSocket Extension:

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

Create the Configuration File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
jupyter notebook --generate-config

Open the Jupyter Directory:

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

Create the SSL Certificate:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
  4. Enter “US” into “Country Name”
  5. Press “Enter”
  6. Enter “.” into the remaining fields
  7. Press “Enter”
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem

Create the JSON File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
echo "" > $HOME/.jupyter/jupyter_notebook_config.json

Open the JSON File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
notepad $HOME/.jupyter/jupyter_notebook_config.json

Edit the JSON File:

  1. Copy the JSON from below these instructions
  2. Paste the JSON into Notepad
  3. Change “Admin” to the Windows username
  4. Change “User” to the Unix username
  5. Click the “File” menu
  6. Click “Save”

Create the Password:

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

Open the Firewall Settings:

  1. Press “⊞ Windows”
  2. Enter “Windows Defender Firewall” into the search bar
  3. Click “Windows Defender Firewall”
  4. Click “Advanced Settings” in the left panel

Create an Inbound Rule:

  1. Click “Inbound Rules” in the left panel
  2. Click “New Rule…” in the right panel

Specify the Port:

  1. Select “Port”
  2. Click “Next”
  3. Select “Specific Local Ports”
  4. Enter “8888”
  5. Click “Next”

Allow the Connection:

  1. Select “Allow the Connection”
  2. Click “Next”

Complete the Inbound Rule:

  1. Check “Domain”, “Private” and “Public”
  2. Click “Next”
  3. Copy the name from below these instructions
  4. Paste the name into the “Name” text box
  5. Click “Finish”
Jupyter Notebook Server (WSL2)

Exit WSL2:

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

Change the Execution Policy:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
Set-ExecutionPolicy Unrestricted -Force

Create the Visual Basic Script File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
echo "" > $HOME\.jupyter\jupyter_notebook_server_wsl2.vbs

Open the Visual Basic Script File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
notepad $HOME\.jupyter\jupyter_notebook_server_wsl2.vbs

Edit the Visual Basic Script File:

  1. Copy the code from below these instructions
  2. Paste the code into Notebook
  3. Click the “File” menu
  4. Click “Save”
set object = createobject("wscript.shell") 
object.run "bash.exe -c '~/.pyenv/shims/jupyter-notebook --no-browser --config ~/.jupyter/jupyter_notebook_config.json'", 0

Open Task Scheduler:

  1. Press “⊞ Windows”
  2. Enter “Task Scheduler” into the search bar
  3. Click “Task Scheduler”

Create the Task:

  1. Click “Create Basic Task” in the right panel
  2. Copy the name from below these instructions
  3. Paste the name into the “Name” text field
  4. Click “Next”
  5. Select “When the Computer Starts”
  6. Click “Next”
  7. Select “Start a Program”
  8. Click “Next”
Jupyter Notebook Server (WSL2)

Specify the Action:

  1. Copy the path from below these instructions
  2. Paste the path into the “Program/Script” text field
  3. Click “Next”
  4. Check “Open the Properties Dialog…”
  5. Click “Finish”
%USERPROFILE%\.jupyter\jupyter_notebook_server_wsl2.vbs

Specify the Trigger:

  1. Click “Triggers” in the top tab bar
  2. Click “At Startup”
  3. Click “Edit”
  4. Check “Delay Task For”
  5. Enter “30 Seconds”
  6. Click “OK”

Run the Task as the User:

  1. Click “General” in the tab bar
  2. Check “Run With Highest Privileges”

Remove the Time Limit:

  1. Click “Settings” in the tab bar
  2. Uncheck “Stop the Task if It Runs Longer Than”
  3. Click “OK”
  4. Restart the computer

Get the Network Configuration Information:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
  4. Write down the IPv4 Address, Subnet Mask, and Default Gateway.
  5. Write down the DNS Servers.
powershell.exe ipconfig /all

Log into the Router:

  1. Open the web browser
  2. Copy the router IP address from below these instructions
  3. Paste the router IP address into the web browser
  4. Press “Enter”
  5. Log into the router
192.168.0.1

Set up Port Forwarding:

  1. Find the “Port Forwarding” page
  2. Paste the IPv4 address into the “Enter IP Address” text field
  3. Copy the port from below these instructions
  4. Paste the port into the “WAN Starting Port” text field
  5. Paste the port into the “WAN Ending Port” text field
  6. Select “All IP Addresses”
  7. Click “Apply”
8888

Open the Network Adapter Properties:

  1. Press “⊞ Windows”
  2. Enter “Network Status”
  3. Click “Network Status”
  4. Click “Change Adapter Options”
  5. Right-click the network adapter that’s connected to the internet
  6. Click “Properties”

Set the Static IP Address:

  1. Select “Internet Protocol Version 4 (TCP/IPv4)”
  2. Click “Properties”
  3. Select “Use the Following IP Address”
  4. Enter the TCP/IP information from earlier
  5. Select “Use the Following DNS Server Addresses”
  6. Enter the TCP/IP information from earlier
  7. Click “OK”

Install Net-Tools:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
wsl --exec sudo apt install net-tools

Open the Jupyter Directory:

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

Create the PowerShell File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
Set-Content jupyter_notebook_port_wsl2.ps1 "" -Encoding ASCII

Open the PowerShell File:

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

Edit the PowerShell File:

  1. Copy the script from below these instructions
  2. Paste the script into Notepad
  3. Click the “File” menu
  4. Click “Save”

Open Task Scheduler:

  1. Press “⊞ Windows”
  2. Enter “Task Scheduler” into the search bar
  3. Click “Task Scheduler”

Create the Task:

  1. Click “Create Basic Task” in the right panel
  2. Copy the name from below these instructions
  3. Paste the name into the “Name” text field
  4. Click “Next”
  5. Select “When the Computer Starts”
  6. Click “Next”
  7. Select “Start a Program”
  8. Click “Next”
Jupyter Notebook Port (WSL2)

Specify the Action:

  1. Copy the path from below these instructions
  2. Paste the path into the “Program/Script” text field
  3. Click “Next”
  4. Click “Yes”
  5. Check “Open the Properties Dialog…”
  6. Click “Finish”
powershell.exe -File %userprofile%\.jupyter\jupyter_notebook_port_wsl2.ps1

Specify the Trigger:

  1. Click “Triggers” in the top tab bar
  2. Click “At Startup”
  3. Click “Edit”
  4. Check “Delay Task For”
  5. Enter “30 Seconds”
  6. Click “OK”

Run the Task in the Background:

  1. Click “General” in the tab bar
  2. Select “Run Whether User Is Logged On or Not”
  3. Check “Run With Highest Privileges”
  4. Click “OK”
  5. Restart the computer

Access the Server From the Local Network:

  1. Log into a different computer or laptop
  2. Connect to the same WiFi network
  3. Enter the IPv4 Address into the web browser
  4. Prepend “https://” to the IP address
  5. Append “8888” to the IP address
  6. Press “Enter”
  7. Type “thisisunsafe”
  8. Enter the password
  9. Click “Log In”

Get the Public IP Address:

  1. Copy the URL from below these instructions
  2. Paste the URL into the web browser
  3. Write down the public IP address
https://www.google.com/search?q=whatsmyip

Access the Server From a Remote Network:

  1. Log into a different computer or laptop
  2. Connect to a different WiFi network
  3. Enter the public IP address into the web browser
  4. Prepend “https://” to the IP address
  5. Append “8888” to the IP address
  6. Press “Enter”
  7. Type “thisisunsafe”
  8. Enter the password
  9. Click “Log In”

“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